Java LinkedHashMap() Constructor
Syntax
LinkedHashMap() constructor from LinkedHashMap has the following syntax.
public LinkedHashMap()
Example
In the following code shows how to use LinkedHashMap.LinkedHashMap() constructor.
import java.util.LinkedHashMap;
//w w w .j a v a 2 s . c om
public class Main {
public static void main(String[] args) {
LinkedHashMap<String, Integer> map = new LinkedHashMap<String, Integer>();
// add some values in the map
map.put("One", 1);
map.put("Two", 2);
map.put("Three", 3);
System.out.println(map);
// clear the map
map.clear();
System.out.println(map);
}
}
The code above generates the following result.
Home »
Java Tutorial »
java.util »
Java Tutorial »
java.util »