Given below the sample code :
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.NavigableSet;
import java.util.TreeSet;
public class Check {
public static void main(String... args) {
List<Integer> mylist = new ArrayList<Integer>();
lst.add(21);
lst.add(3);
lst.add(6);
lst.add(9);
lst.add(30);
lst.add(12);
NavigableSet<Integer> nset = new TreeSet(mylist);
System.out.println(nset.headSet(10));
}
}
What will be the output of the above code ?
1. Compile error
2. 3 6 9
3. 12 21 30
4. 9
(2)
headSet(10) Returns the elements which are strictly less than 10.
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.