This is not an exact answer to this question, but in case the objects should be sorted SortedSet has a first() method:
SortedSet sortedSet = new TreeSet();
sortedSet.add("2");
sortedSet.add("1");
sortedSet.add("3");
String first = sortedSet.first(); //first="1"
The sorted objects must implement the Comparable interface (like String does)