TreeMap in Java

import java.util.TreeMap;
 
public class dimensionsExample {
   public static void main(String[] args) {
      TreeMap<String,String> dimensions = new TreeMap<String,String>();
      dimensions.put("NC", "2333");
      dimensions.put("NY", "2334");
      dimensions.put("SC", "2335");
      dimensions.put("CA", "2336");
      System.out.println("CA: " + dimensions.get("CA"));
      dimensions.put("AZ", "2337");
      System.out.println("Size of dimensions: " + dimensions.size());
      dimensions.remove("SC");
      System.out.println("Size of dimensions: " + dimensions.size());
   }
}

Enjoyed this post? Share it!

 

Leave a comment

Your email address will not be published.