Given below the sample code :
import java.util.ArrayList;
import java.util.List;
import java.util.NavigableSet;
import java.util.TreeSet;
public class CheckTail{
public static void main(String... args) {
List<Integer> MyList = new ArrayList<Integer>();
MyList.add(21);
MyList.add(3);
MyList.add(3);
MyList.add(3);
MyList.add(30);
MyList.add(2);
NavigableSet<Integer> ngs = new TreeSet<Integer>(MyList);
System.out.println(ngs.tailSet(3));
}
}
What will be the output of the above code ?
1. Compilation error
2. [21, 3, 30, 2]
3. [3, 30, 2]
4. [ 3, 21, 30]
(4)
The ' tailSet(3) ' returns elements which are greater than or equal to 3.
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.