8:58 am - Friday May 25, 2018

TreeMap example program for put()

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

/**
*@author :CandidJava.com
*@descriptions : This program explain the function and use of put() method
*/
import java.util.TreeMap;

class TreeMap {
public static void main(String[] args) {
// creating TreeMap Object
TreeMap treeMap = new TreeMap();
// put()method is used to insert the values into the Map
treeMap.put("One", new Integer(1));
treeMap.put("Two", new Integer(2));
// get()method is used to call the particular value from the Map
Object obj = treeMap.get("Two");
System.out.println(obj);
}
}

Output:

D:\CandidJava\Util\TreeMap>javac TreeMap1.java

Note: TreeMap1.java uses unchecked or unsafe operations.

Note: Recompile with -Xlint:unchecked for details.

D:\CandidJava\Util\TreeMap>java TreeMap1

BACK

Filed in: Z-A All Java Codes

No comments yet.

Leave a Reply