Java: Get first item from a collection
Looks like that is the best way to do it: String first = strs.iterator().next(); Great question… At first, it seems like an oversight for the Collection interface. Note that “first” won’t always return the first thing you put in the collection, and may only make sense for ordered collections. Maybe that is why there isn’t … Read more