You can not just put some entry as first entry in treemap. There is another way way to achieve it, while creating the TreeMap pass custom Comaparator
.
And in the Comparator<? super K> comparator
write a logic that Orange should come in first element. It ensure you that "Orange" would be always first element of the map.
Code snippet :
Comparator<String> customComparator = new Comparator<String>() {
@Override public int compare(String s1, String s2) {
// Add null check
if(s1.equals("Orange"))
return 1;
else if(s2.equals("Orange"))
return -1;
return s1.compareTo(s2);
}
};
...
SortedMap<String,String> map = new TreeMap<String,String>(customComparator );