Consider the following program and predict the output:
import java.util.*; public class Main { public static void main(String []args) { Map<Integer, String> map = new TreeMap<Integer, String>(); map.put(5, "5"); map.put(10, "10"); map.put(3, "3"); map.put(5,"25"); System.out.println(map); }// w w w. j a v a2s . c om }
d)
TreeMap is a Map;-a value is stored against a key, and the elements are sorted based on the key.
Option c) is not possible since two values cannot exist for a key.
In a Map, keys are sequential, so options a) and b) are not possible.
Option e) is also not correct since you have overwritten the value 25 against key 5, which is not captured by option e).