0
explain how it is working and what is arr[i] = new int[i + 1];
public static void main(String args[]) { int m = 3; int arr[][] = new int[m][]; for(int i = 0; i < arr.length; i++) { arr[i] = new int[i + 1]; for(int j = 0; j < arr[i].length; j++) { arr[i][j] = i; System.out.print(arr[i][j] + " "); } System.out.println(); } } }
3 Answers
0
i learnt c lang already now i m learning java
i learnt about loops in c but this is something different i dont understand whats happening here and how output is get calculated
0
arr[i] = new int[i + 1];
//initializing column size as i+1 of elements, for i'th row
- 1
But values of i one by one if u know how to use loop u can easily calculate