What will be the output of the following program?
TreeSet
set.add("apple");
set.add("banana");
set.add("cherry");
set.add("date");
set.add("banana");
Iterator
while (iterator.hasNext()) {
System.out.print(iterator.next() + " ");
}
1
apple banana cherry date
2
date cherry banana apple
3
banana apple date cherry
4
apple banana cherry date banana
5
Question Not Attempted