• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

java collection problem

 
manish gupta
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I have a problem to get the one object from the collection of two objects.
object what I want from collection should be higher value (one of the attribute of my object) from other object in same collection.


I would be appreciate you if help me to resolve this problem.

Thanks in advance
Manish
 
Campbell Ritchie
Sheriff
Posts: 48652
56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try the Collections.sort() method. Then you get the contents of the collection in order, I think smallest first. The sort method requires you to implement the Comparable<T> interface on your objects, or to create a class from the Comparator<T> interface.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic