Array inside android array

I do not know how to do that. But I want to create two arrays .. one for the array class, and the other for the information that I will use for the selected class, which uses for the loop. I prefer for the loop that for each loop .. ^ _ ^ .. My question is. Is it possible to create an array in which it will store the array? eg:

private final Class<?>[] cls = {class1,class2,class3}; private final String[] myFirstArray = {array1[],array2[],array[]3}; private final String selectedarray[]; for(int i=0;i<cls.lenght();i++){ if(myArrayClassParameter == cls[i]){ selectedArray[] = myFirstArray[i]; } } 

Like this?

Well, if possible, my work will be less laborious .. thanks.

+4
source share
2 answers

Absolutely - you can create arrays of arrays or even arrays of arrays of arrays, etc. All you need to do is add a few pairs of square brackets [] .

 private final String[][] firstArray = new String[][] { new String[] {"quick", "brown", "fox"} , new String[] {"jumps", "over", "the"} , new String[] {"lazy", "dog", "!"} }; String[] selectedArray = firstArray[1]; 
+6
source

Yes. They are called multidimensional arrays . Try them and chat with them. You will learn this.

You must declare them as follows:

 Type[] smallerArray1; Type[] smallerArray2; Type[] smallerArray3; Type[][] biggerArray = new Type[][]{smallerArray1, smallerArray2, smallerArray3}; 

Then you can use them as regular arrays.

+1
source

All Articles