Java TreeMap Example - remove() Methodrefer touttual:ri.com/**
* @author lautturi.com
* Java example: Java TreeMap remove method
*/
import java.util.*;
public class Lautturi {
public static void main(String[] args) {
TreeMap<Integer, String> map = new TreeMap<Integer, String>();
map.put(5, "Apple");
map.put(7, "banana");
map.put(1, "Cherry");
map.put(33, "Orange");
map.put(9, "pear");
map.put(23, "Lautturi");
for (Map.Entry entry : map.entrySet()) {
System.out.println(entry.getKey() + " " + entry.getValue());
}
map.remove(33);
map.remove(1);
System.out.println("\\nAfter using remove() method:");
for (Map.Entry entry : map.entrySet()) {
System.out.println(entry.getKey() + " " + entry.getValue());
}
}
}