Answers for "java hashset get first element"

1

how to get first element from hashset in java

Collection c;

Iterator iter = c.iterator();

Object first = iter.next();
Posted by: Guest on April-08-2021
0

get first entry in set java

Set<Long> set = new LinkedHashSet<>();
set.iterator().next();
// LinkedHashSet guarantees insertion order
Posted by: Guest on December-09-2020
0

how to find first value of an list

// Python
list = [1,2,3]
firstdigit = list[0] // 1 

list = ['Hello', 'bye', 'Adios']
firstvalue = list[0] // 'Hello'
Posted by: Guest on May-09-2020

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language