10:59 pm - Thursday February 23, 2017

Add key value pair to Treemap V put(K key,V value)

CANDID INDUSTRIAL TRAINING -- CHENNAI
Corporate Training for Experienced Candidate
Struts | Hibernate | Spring | Java / J2EE
SOAP | RestFull | Design Pattern | more...
Ph: +91 72000 69003
137b, 2nd st, shanthi nagar, Chrompet, Chennai -600044

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

 

Filed in: Java Examples

Comments are closed.