---
title: "How to Create an LinkedList<String, int>"  
description: "How to Create an LinkedList<String, int>"  
author: "Anonymous User"  
published: 2013-10-04  
updated: 2013-10-04  
canonical: https://www.mindstick.com/forum/1576/how-to-create-an-linkedlist-string-int  
category: "java"  
tags: ["java"]  
reading_time: 1 minute  

---

# How to Create an LinkedList<String, int>

I want to create an [LinkedList](https://www.mindstick.com/forum/159619/when-to-use-linkedlist-over-arraylist-in-c-sharp) of couple that the key is a [String](https://www.mindstick.com/articles/1527/string-split-in-c-sharp) and the [value](https://www.mindstick.com/articles/23219/an-optimized-description-adds-value-to-experience-and-in-turn-effectively-guest-posting-packages) is an [integer](https://answers.mindstick.com/qa/113667/write-code-for-roman-to-integer) ?

## Replies

### Reply by Anonymous User

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).


---

Original Source: https://www.mindstick.com/forum/1576/how-to-create-an-linkedlist-string-int

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
