I want to create an LinkedList of couple that the key is a String and the value is an integer ?
How to Create an LinkedList<String, int> Anonymous User 2779 04 Oct 2013 I want to create an LinkedList of couple that the key is a String and the value is an integer ?
You can only use Object in a LinkedList., this means you cant use Java Primitives. However, what you seem to need is a Map structure.
I recommend using java.util.HashMap, it allows you to create a Key, Value pairs.
Example:
LinkedHashMap<String, Integer> b = new LinkedHashMap<String,Integer>();
b.put("one",1);
b.put("two",2);
b.put("a",3);
for (String key:b.keySet())
{
System.out.println(b.get(key)); // print 1 then 2 finally 3
}
Hope this is what you were asking (if so, modify your question).