In my code,

```
            SortedMap<Integer, Data> subMap;

            subMap = (db.getDataMap()).tailMap(previousServer);

            SortedMap<Integer, Data>  temp = (db.getDataMap()).headMap(presentServer);
            //System.out.println(subMap);
            //System.out.println(temp);
            subMap.putAll(temp);

```

suppose tailMap() returns nothing, so subMap is an empty Map, but temp has few key-value pair.
So adding temp to subMap via subMap.putAll(temp) is giving me "key out of range".
But if i do temp.putAll(subMap) then everything works fine.

What could be the reason here?