[英]How can I get the data from an ArrayList that store another array inside of that ArrayList (Java)?
I have an ArrayList and this ArrayList have other array inside, I need to obtain the data inside this other array.我有一个 ArrayList 而这个 ArrayList 里面有其他数组,我需要获取这个其他数组中的数据。
This is the structure of the ArrayList and the data inside, I need to get that data这是ArrayList的结构和里面的数据,我需要得到那个数据
This is the code that I use for get all the ArrayList but I need to get the other array that is store in the index(0) and when I can get this data I need to store it in an new Array这是我用于获取所有 ArrayList 的代码,但我需要获取存储在 index(0) 中的另一个数组,当我可以获取此数据时,我需要将其存储在一个新数组中
if (msg.equals("warning")) {
ArrayList<String> dataWarn = (ArrayList<String>) data;
Log.i("api", dataWarn.toString());
To access the inner ArrayList:要访问内部 ArrayList:
ArrayList<String> innerList = data.get(0);
Then you can extract the data inside:然后就可以提取里面的数据了:
String value = innerList.get(0);
And add it to some otherList
:并将其添加到
otherList
:
List<String> otherList = Arrays.asList(value);
You could do the following:您可以执行以下操作:
String[] newArray = new String[outerArray.size()];
for(int i = 0; i<outerArray.size();i++){
newArray[i]=outerArray.get(0).get(0);
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.