What is the result of compiling and running the following code?
import java.util.SortedMap;
import java.util.TreeMap;
public class
Test {
public static void main(
String[] args) {
TreeMap<Integer,String> map = new TreeMap<Integer,String>();
map.put(1, "one");
map.put(2, "two");
map.put(3, "three");
map.put(4, "four");
SortedMap<Integer, String> smap1 = map.tailMap(2);
SortedMap<Integer, String> smap2 = smap1.headMap(4);
SortedMap<Integer, String> smap3 = smap2.subMap(2, 3);
System.out.println(smap3);
}
}
Answers
1 {2=two, 3=three, 4=four}
2 {2=two, 3=three}
3 {2=two}
4 no output is printed
map=[1234]
smap1=[234]
smap2=[234]
smap3=[]
Tell me if I'm wrong and how.