What is the output of the following program?
import java.util.Collection; import java.util.Iterator; import java.util.TreeMap; class Question {/*from w ww . j a v a2 s . co m*/ public static void main(String args[]) { TreeMap map = new TreeMap(); map.put("one", "1"); map.put("two", "2"); map.put("three", "3"); displayMap(map); } static void displayMap(TreeMap map) { Collection c = map.entrySet(); Iterator i = c.iterator(); while (i.hasNext()) { Object o = i.next(); System.out.print(o.toString()); } } }
A. onetwothree B. 123 C. one=1three=3two= D. onethreetwo
C.
A TreeMap sorts its elements by their keys.