can someone tell me how to initialize a 3-d array with (-1) ? i have seen a lecture video in my course in which i think initializing was done wrongly
How to initialize a 3d array with Array.fill?
Arrays.fill takes 1-D Array as an argument.
If you are having a 3-D array lets say arr then you are going to fill it this way :-
int[][][] arr = new int[3][4][5] ;
for(int i = 0 ; i < arr.length ; i++){
for(int j = 0 ; j < arr[0].length ; j++){
Arrays.fill(arr[i][j], -1) ;
}
}
Have faith in your mentors, if you feel initializing is done wrongly, then kindly tell the video name, I will re-check it.