What is the output of the following code snippet? TreeSet<String> set = new TreeSet<String>(); set.add("B"); set.add("A"); set.add("D"); set.add("A"); for(String s : set) { System.out.print(s + " "); } code example

Example 1: What is the output of the following code snippet? TreeSet set = new TreeSet(); set.add("B"); set.add("A"); set.add("D"); set.add("A"); for(String s : set) { System.out.print(s + " "); }

What is the output of the following code snippet?
TreeSet<String> set = new TreeSet<String>();
set.add("B");
set.add("A");
set.add("D");
set.add("A");
for(String s : set) { System.out.print(s + " "); }

Example 2: What is the output of the following code snippet? TreeSet set = new TreeSet(); set.add("B"); set.add("A"); set.add("D"); set.add("A"); for(String s : set) { System.out.print(s + " "); }

What is the output of the following code snippet?
TreeSet<String> set = new TreeSet<String>();
set.add("B");
set.add("A");
set.add("D");
set.add("A");
for(String s : set) { System.out.print(s + " "); }