get first element of hashset java code example
Example 1: how to get first element from hashset in java
Collection c;
Iterator iter = c.iterator();
Object first = iter.next();
Example 2: get first entry in set java
Set<Long> set = new LinkedHashSet<>();
set.iterator().next();
// LinkedHashSet guarantees insertion order
Example 3: java list get first element
list.get(0);
Example 4: java list get first element
!list_or_set.isEmpty()