descendingMap() returns a reverse-order view backed by the same TreeMap, so writes to the original are still visible through it. Only the reading order flips; no elements are copied.
NavigableMap<Integer, String> map = new TreeMap<>();
map.put(1, "one");
map.put(2, "two");
map.put(3, "three");
NavigableMap<Integer, String> desc = map.descendingMap();
System.out.println("Descending: " + desc);
map.put(4, "four");
System.out.println("After adding 4 to original: " + desc);
Descending: {3=three, 2=two, 1=one}
After adding 4 to original: {4=four, 3=three, 2=two, 1=one}
Run this yourself in the Online Java Compiler, spin up a live REST API in the API Sandbox, or practise with Java interview questions.
Published 2026-09-27