Java – Arrays within the array android

Arrays within the array android… here is a solution to the problem.

Arrays within the array android

I don’t know how to do it. But what I want is to create two arrays: One for the array class and the other for the information I will use for the selected class using a for loop. I prefer for loop to each loop: ^_^.. My question is. Is it possible to create an array to store the array? For example:

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 that?

Well, my work would be more time-saving if possible .. Thank you.

Solution

Of course – you can create arrays of arrays, or even arrays of arrays, and so on. You just need to add more 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];

Related Problems and Solutions