GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||||||||||||||||||
GeezerVison is showing www.tutorialspoint.com — Java LinkedHashMap Class
Selected Reading
Java LinkedHashMap ClassIntroductionThe Java LinkedHashMap class is Hash table and Linked list implementation of the Map interface, with predictable iteration order. Following are the important points about LinkedHashMap −
Class declarationFollowing is the declaration for java.util.LinkedHashMap class − public class LinkedHashMap<K,V> extends HashMap<K,V> implements Map<K,V> ParametersFollowing is the parameter for java.util.LinkedHashMap class −
Class constructors
Class methods
Methods inheritedThis class inherits methods from the following classes −
Getting a Value from LinkedHashMap ExampleThe following example shows the usage of Java LinkedHashMap get() method to get a value based on a key from a Map. We've created a Map object of Integer,Integer. Then few entries are added, map is printed. Using get() method, a value is retrieved and printed. package com.tutorialspoint;
import java.util.LinkedHashMap;
public class LinkedHashMapDemo {
public static void main(String args[]) {
// create hash map
LinkedHashMap<Integer,Integer> newmap = new LinkedHashMap<>();
// populate hash map
newmap.put(1, 1);
newmap.put(2, 2);
newmap.put(3, 3);
System.out.println("Initial map elements: " + newmap);
System.out.println("Value: " + newmap.get(1));
}
}
OutputLet us compile and run the above program, this will produce the following result. Initial map elements: {1=1, 2=2, 3=3}
Value: 1
Advertisements
| ||||||||||||||||||||||||
| You are visitor 01402503 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |