7:44 pm - Sunday September 23, 2018

Java program for LinkedHashMap by using clone()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 LinkedHashMapclone {
public static void main(String args[]) {
// creating LinkedHashMap Object
LinkedHashMap lhm = new LinkedHashMap();
System.out.println("Initial LinkedHashMap:" + lhm.size());
lhm.put(1, "mani");
lhm.put(6, "karthi");
lhm.put(5, "Bala");
lhm.put(4, "Anand");
lhm.put(3, "candid");
// clone() method is used to generate the duplicate value of the object
lhm.clone();
System.out.println("TheLinkedHashMap are : " + lhm);
}
}

/**output

D:\CasndidJava\Util\LinkedHashMap>javac LinkedHashMapclone.java

Note: LinkedHashMapclone.java uses unchecked or unsafe operations.

Note: Recompile with -Xlint:unchecked for details.

D:\CandidJava\Util\LinkedHashMap>java LinkedHashMapclone

Initial LinkedHashMap:0

TheLinkedHashMap are : {1=mani, 6=karthi, 5=Bala, 4=Anand, 3=candid}

*/

Filed in: Z-A All Java Codes

No comments yet.

Leave a Reply