Computer Science, asked by Rahulpachauri8601, 1 year ago

public class Topper { public static void main(String args[]) { TreeSet ts=new TreeSet(); ts.add("30"); ts.add("90"); ts.add("100"); ts.add("40"); ts.add("90"); System.out.println(ts); } }

Answers

Answered by charlie1505
1

Explanation:

output will be-

[30

40

90

100]

Answered by pragyakirti12345
0

Answer: [30, 40, 90, 100]

Concept : Treeset

Given : public class Topper { public static void main(String args[]) {

            TreeSet ts=new TreeSet(); ts.add("30"); ts.add("90"); ts.add("100");

            ts.add("40"); ts.add("90"); System.out.println(ts); } }

To Find : Expected output of the program

Explanation:

TreeSet is an implementation of sorted set interface , that uses a tree for storage. The ordering of the elements is maintained by a set and is by default ascending in nature. TreeSet implements the Set interface in Java.

public class Topper

{

public static void main(String args[])

{

TreeSet ts=new TreeSet();

ts.add("30");

ts.add("90");

ts.add("100");

ts.add("40");

ts.add("90");

System.out.println(ts);

}

}

Output :

[30, 40, 90, 100]

#SPJ3

Similar questions