10:41 am - Thursday January 19, 2017

Retrieve value of given Key in Treemap V get(Object key)

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 Retrieve value of given Key in treemap using get(Object key) method.  Returns the value to which the specified key is mapped, or null if this map contains no mapping for the key.

Example


import java.util.TreeMap;

public class TreeMapGetValue

{

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);

   System.out.println("Value of second: "+hm.get("second"));

 }

}

 

Output

           {first=FIRST INSERTED, second=SECOND INSERTED, third=THIRD INSERTED}

            Value of second: SECOND INSERTED

BACK

Filed in: Java Examples, Z-A All Java Codes

Comments are closed.