Question: I just created this method for a 2D array but is throwing me an exception. I want it to do this with a certain number
I just created this method for a 2D array but is throwing me an exception.
I want it to do this with a certain number of rows.

This is my method:
private void createTriangle() { //Initializing the array with 1 more than the size of the rows array = new int[rows][];
array[0] = new int[1];//declaring number of elements in row array[1] = new int[2];//declaring number of elements in row
array[0][0] = 1;// Store a 1 in the first column of the first row // Store a 1 in the first column of every from the second one on array[1][0] = 1; // Store a 1 in the last column of every row from the second one on array[1][1] = 1; for (int i = 2; i
for (int i = 2; i 1. Store a 1 in the first column of the first row 2. Store 1's in the first column and second columns of the second row 3. For each additional row, do: - Store 1's in the first and last columns For every other column, store the sum of the values in the previous row previous column and previous row, same column
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
