3:09 am - Friday April 19, 2019

program for LinkedHashMap by using get () 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

*@author :CandidJava.com

*@descriptions : This program explain the function and use of get() method

/**LinkedHashMap get*/

import java.util.*;

import java.util.LinkedHashMap;

class LinkedHashMapget{

public static void main(String args[]) {

//creating LinkedHashMap Object

LinkedHashMap lhm = new LinkedHashMap();

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

//get method is used to call the elemet from the list

Object o=lhm.get(4);//Object obj = lhm.remove(5);/**Removed from key and values*/

//to convert the object values into string

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 LinkedHashMapget.java

Note: LinkedHashMapget.java uses unchecked or unsafe operations.

Note: Recompile with -Xlint:unchecked for details.

D:\CandidJava\Util\LinkedHashMap>java LinkedHashMapget

InitialLinkedHashMap are : 0

Final of LinkedHashMap are : 5

Final of LinkedHashMap are : Anand

Filed in: Z-A All Java Codes

No comments yet.

Leave a Reply