I'm having a hard time to figure out on how to merge multidimensional array into one single array.
Here is my code:
String[][] multiArray = {{"1","2","3"},{"4","5","6"}};
String[] singleArray = new String[6];
for(int i=0; i<singleArray.length; i++)
{
for(int x=0; x<multiArray.length; x++)
{
for(int z=0; z<multiArray[x].length;z++)
{
//for(int i=0; i<singleArray.length; i++)
//{
singleArray[i] = multiArray[x][z];
//}
}
}
}
for(String temp : singleArray){
System.out.println(temp);
}
The RESULT is
6
6
6
6
6
6
Why is that? How can I put all the numbers into one single array? Many thanks!