Add and get value to TreeMap - Java Collection Framework

Java examples for Collection Framework:TreeMap

Description

Add and get value to TreeMap

Demo Code

 
import java.util.TreeMap;
 
public class Main {
 
  public static void main(String[] args) {
    TreeMap treeMap = new TreeMap();
    treeMap.put("One", new Integer(1));
    treeMap.put("Two", new Integer(2));
    Object obj = treeMap.get("Two");
    System.out.println(obj);  /* w  w w.j  a  v a  2 s.  co m*/
  }
}

Result


Related Tutorials