For example a 2-D array to a 3-D array.Is it possible using array ? If not, what class should I use to achieve this ?
EDIT : The array dimension is user defined at runtime.
For example a 2-D array to a 3-D array.Is it possible using array ? If not, what class should I use to achieve this ?
EDIT : The array dimension is user defined at runtime.
You can't change length or dimension of an array, but you can create a new array with different number of dimensions and copy the content of the old array into it.
Small example
int[] initialArray = new int[]{1,2,3};
System.out.println(initialArray[0] + " " + initialArray[1] + " "+ initialArray[2]);
int[][] newArray = new int[initialArray.length][3];
for (int i=0;i<initialArray.length;i++){
newArray[i][0] = initialArray[i];
}
System.out.println(newArray[0][0] + " " + newArray[1][0] + " "+ newArray[2][0]);