当我需要一种在 ArrayList 中轻松识别 ArrayList 的方法时,我只需将标识符放在 0 索引中,然后用循环打印出所有零索引。 现在我想知道是否有办法让嵌套的 ArrayList 具有名称。
例如:
ListOfLists.add( new ArrayList<String>() );
ListOfLists.get(ListOfLists.size() -1).add("someIdentifierHumansCanRead");
有什么方法可以使ListOfLists.add(new ArrayList<String>())
是
ListOfLists.add(ArrayList someIdentifierHumansCanRead = new ArrayList<String>)
?
或者这会完全荒谬吗?
最佳答案
你说的是 map ,其中所有数组列表都由字符串键入 - 但你将失去迭代顺序。或者,您可以将键存储在数组列表中,将数组列表存储在映射中。
关于java - 在 Java 中有没有办法在 ArrayList 中命名一个 ArrayList?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12996401/