11:15 pm - Sunday February 19, 2017

Retrieve value of given Key in LinkedHashMap 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

                            The method public V get(Object key) returns a value to which the key is mapped. It returns null if there is no mapping for the given key.

Example Program


import java.util.LinkedHashMap;

public class LinkedHashMapKeySet {

	public static void main(String[] args) {

		LinkedHashMap lhm = new LinkedHashMap();

		lhm.put("Add", "+");

		lhm.put("Sub", "-");

		lhm.put("Mul", "*");

		System.out.println("Map:" + lhm);

		// get key "Mul"

		System.out.println("" + lhm.get("Mul"));

		// get key "Div"

		System.out.println("" + lhm.get("Div"));

	}

}

Output

  Map:{Add=+, Sub=-, Mul=*}

     *

   null

BACK

 

 

 

 

 

Filed in: Java Examples

Comments are closed.