Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Java

Compare property values from a ArrayList Object

Hi there, hope for some help, i have a object where i store some propertys, where one of them is "price", i created a Arraylist to add objects/items to the Arraylist than compare the lowest price from the Arraylist, but i dont have no ideia how to do it, can someone give me some hint? regards

1 Answer

Craig Dennis
STAFF
Craig Dennis
Treehouse Teacher

See Collections.sort. In the official tutorial here, look specifically at the Comparator EmpSort. If you sort your collection by price you can get the first element.

Hope that helps, this stuff is coming soon!