How to get an element from a Set?

I have a Set<Integer> in my Java program which is guaranteed to be non-empty. I want to retrieve one of the Integers from this set. I do not care which Integer, I just need some Integer, deterministically or nondeterministically selected from the set, as long as it is in the set. What is the best way to do this?

Jon Skeet
people
quotationmark

Why not just take the first element?

return set.iterator().next();

If it's guaranteed to be non-empty, and you don't care which element you retrieve, this sounds about as simple as it gets.

people

See more on this question at Stackoverflow