Hi Team,
Im reading collections and there is a topic called Backed Collections. I could not understand the output below . Please throw some light on it.
TreeMap<String,String> map = new TreeMap<String,String>();
map.put("a","ant");
map.put("d","dog");
map.put("h","horse");
SortedMap<String,String> submap;
submap = map.subMap("b","g");
System.out.println(map + " " + submap);
map.put("b", "bat");
submap.put("f","fish");
map.put("r", "raccoon");
// submap.put("p" , "pig"); // out of range
System.out.println(map + " " + submap);
** OUTPUT **
{a=ant, d=dog, h=horse} {d=dog}
{a=ant, b=bat, d=dog, f=fish, h=horse, r= racoon} { b=bat, d=dog, f=fish}
Please explain the output and one comment inside the code which says "out of Range".