3:53 pm - Thursday March 25, 0793

Java program for LinkedHashMap by using generic () method

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

import java.util.*;
import java.util.LinkedHashMap;

class LinkedHashMapgeneric {
public static void main(String args[]) {
// creating LinkedHashMap Object
LinkedHashMap<Integer, String> lhm = new LinkedHashMap<Integer, String>();
System.out.println("InitialLinkedHashMap are : " + lhm.size());
lhm.put(1, "mani");
lhm.put(6, "karthi");
lhm.put(5, "Bala");
lhm.put(4, "Anand");
lhm.put(3, "candid");
String s = lhm.get(4);// Object obj = lhm.remove(5);/**Removed from key
// and values*/
// String s=(String)o;
System.out.println("Final of LinkedHashMap are : " + lhm.size());
System.out.println("Final of LinkedHashMap are : " + s);

}
}

/**output

D:\CandidJava\Util\LinkedHashMap>javac LinkedHashMapSize.java

Note: LinkedHashMapSize.java uses unchecked or unsafe operations.

Note: Recompile with -Xlint:unchecked for details.

D:\CandidJava\Util\LinkedHashMap>java LinkedHashMapSize

InitialLinkedHashMap are : 0

Final of LinkedHashMap are : 4

*/

Filed in: Z-A All Java Codes

No comments yet.

Leave a Reply