Two dimensional array list

前端 未结 9 1307
梦毁少年i
梦毁少年i 2020-11-28 05:09

I\'ve heard of using a two dimensional array like this :

String[][] strArr;

But is there any way of doing this with a list?

Maybe s

9条回答
  •  悲&欢浪女
    2020-11-28 05:34

    You can create a list,

    ArrayList outerArr = new ArrayList(); 
    

    and add other lists to it like so:

    String[] myString1= {"hey","hey","hey","hey"};  
    outerArr .add(myString1);
    String[] myString2= {"you","you","you","you"};
    outerArr .add(myString2);
    

    Now you can use the double loop below to show everything inside all lists

    for(int i=0;i

提交回复
热议问题