BACK
This tutorial explains how to Add key value pair to Treemap using V put() method.It Associates the specified value with the specified key in this map.
Example
import java.util.java.util.TreeMap; public class TreeMapPut { public static void main(String a[]) { TreeMap<String, String> hm = new TreeMap<String, String>(); hm.put("first", "FIRST INSERTED"); hm.put("second", "SECOND INSERTED"); hm.put("third","THIRD INSERTED"); System.out.println(hm); } }
Output
{first=FIRST INSERTED, second=SECOND INSERTED, third=THIRD INSERTED}
BACK