我当前正在尝试将字符串数组列表保存到字符串数组数组列表中。下面的代码显示了我正在尝试的基础知识。
ArrayList<ArrayList<String>> groupCollection= new ArrayList<ArrayList<String>>();
ArrayList<String> m_listItems = new ArrayList<String>();
groupCollection.add(m_listItems);
我将字符串添加到 m_listItems
使用相同的.add()
功能并正确添加字符串。
但是在调试器中,当我尝试添加 m_listItems
时(实际上里面有一个值数组)进入 groupCollection
的第一个索引,它将一个空数组添加到第一个索引中。
最佳答案
你的代码没问题,那不是 null,只是一个空数组列表!
关于java - 将 ArrayList<String> 添加到 ArrayList<ArrayList<String>>,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38087241/