Menu
Question Index
...

What will be the output of the following program?

import java.util.*;
public class Master {
    public static void main(String[] args) {
        TreeSet map = new TreeSet();
        map.add("one");
        map.add("two");
        map.add("three");
        map.add("four");
        map.add("one");
        Iterator it = map.iterator();
        while (it.hasNext()) {
            System.out.print(it.next() + " ");
        }
    }
}


one two three four
four three two one
four one three two
one two three four one
Compilation Error or Runtime Error

Doubts

Problems

Topic: Java Iterator

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App