如何在Java中制作二维LinkedList? [英] How to make two dimensional LinkedList in java?
问题描述
例如:
public static LinkedList<String, Double> ll = new LinkedList<String, Double>;
推荐答案
从您的问题来看,我认为(不是100%肯定)
java.util.LinkedHashMap<K, V>
from your question, I think (not 100% sure) you are looking for
java.util.LinkedHashMap<K, V>
在您的情况下为LinkedHashMap<String, Double>
来自Java文档:
Map接口的哈希表和链表实现,具有 可预测的迭代顺序.此实现不同于HashMap 因为它维护了遍历其所有列表的双向链表 项.
Hash table and linked list implementation of the Map interface, with predictable iteration order. This implementation differs from HashMap in that it maintains a doubly-linked list running through all of its entries.
如果您确实想通过list.get(5)
获取元素,则可以:
if you do want to get element by list.get(5)
, you could :
LinkedList<Entry<String, Double>>
因此您可以通过Entry entry = list.get(5)
获取Entry元素,然后entry.getKey()
给您STRING,而entry.getValue()
给您Double.
so you can get Entry element by Entry entry = list.get(5)
, then entry.getKey()
gives you the STring, and entry.getValue()
gives you the Double.
这篇关于如何在Java中制作二维LinkedList?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!