treeset last 28 29 method in java

Solutions on MaxInterview for treeset last 28 29 method in java by the best coders in the world

showing results for - "treeset last 28 29 method in java"
Thiago
11 Jan 2018
1TreeSet last() method when elements are String types.
2import java.util.TreeSet;
3public class TreeSetLastMethodExample
4{
5   public static void main(String[] args)
6   {
7      TreeSet<String> ts = new TreeSet<String>();
8      ts.add("grapes");
9      ts.add("banana");
10      ts.add("watermelon");
11      ts.add("apple");
12      // print last highest element
13      System.out.println("Last highest element is: " + ts.last());
14   }
15}
Olivier
29 Jan 2020
1import java.util.TreeSet;
2public class TreeSetLastMethodExample
3{
4   public static void main(String[] args)
5   {
6      TreeSet<Integer> ts = new TreeSet<Integer>();
7      ts.add(58);
8      ts.add(42);
9      ts.add(29);
10      ts.add(10);
11      // print last highest element
12      System.out.println("Last highest element is: " + ts.last());
13   }
14}