Originally posted by arironen
how is it done?!
in java, we call them methods.. are you a c programmer? in java, the array pointers are handled for you.. just use their name as a reference to the whole array, and make sure the types are consistent
public void myMethod(TYPE NAME, TYPE2 NAME2, TYPE3 NAME3... etc ...)
so a 5 dimensional array of ints is:
int[][][][][] the5D....
and to pass it to a method:
public void methodTakes5DArray(int[][][][][] fiveDim){
}
note that arrays can be stripped of their dimension, as a 5D array can be thought of as an array of 4Dimensional arrays:
Code:
//declare an array of ten, 4D arrays:
int[][][][][] the5D = new int[10][][][][];
public void methodTakesA4DArray(int[][][][] the4D){
...
}
and elsewhere:
for(int i=0; i<10; i++){ //better to write i<the5D.length
//call the 4D method
methodTakesA4DArray(the5D[i]);
}
Bookmarks