Menu
Question Index
...

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

Input (TreeSet) Output (Integer)
[412, 410, 402, 404, 405, 406, 409, 411] 402
[15, 25, 99, 40, 10, 20, 30] 10
[21, 2, 31, 25, 30, 0, 32, 22, 12] 0
null null


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

    }


    public static Integer getLowestElement(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