I am creating an array but cannot add values to it.
ArrayList[] lists = (ArrayList[])new ArrayList[count];
for(int i=0;i
{
String number="",id="";
number = temp.get(i).addr;
id = temp.get(i).thread_id;
lists[i].add(temp.get(i)); // Problem here
}
I am unable to add value to it
解决方案
You're creating an array of null references, so you need to initialize each of them to a new ArrayList():
for (int i = 0; i < count; i++) {
lists[i] = new ArrayList();
}