Menu
Question Index
...

Write a program to get the highest element from given input using one of the TreeSet methods.
Note the elements in TreeSet by default sorted in ascending order.

Input (TreeSet) Output (Integer)
[10, 15, 25, 99, 40, 20, 30] 99
[0, 21, 2, 31, 25, 30, 32, 22, 12] 32
[1, 7, 2, 8, 3, 4, 5, 6] 8
null null


import java.util.*;
class GetHighestElement
{
    public static void main(String s[])
    {
        TreeSet input = new TreeSet();
        input.add(1);
        input.add(3);
        input.add(2);
        input.add(5);
        input.add(4);
        System.out.println("The highest element is : " + getHighestElement(input));

    }


    public static Integer getHighestElement(TreeSet input) {
    }

}

Doubts

Problems

Topic: Java TreeSet - TreeSet Examples in Java

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App