Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I'm trying to take the original 2d array ( one where the user enters the number of rows and columns and then it gets filled

I'm trying to take the original 2d array ( one where the user enters the number of rows and columns and then it gets filled with random numbers) and change the row and columns in it by pointing the reference variable. Then after that, I need to reinitialize all the values in the array to 0.

//here's the part of my program when I try to make the new 2d array

public static int[][] newArray(int[][] matrix) { int[][]newMatrix= new int[4][5]; for(int newRow=0; newRow < newMatrix.length; newRow++) { for(int newCol=0; newCol < newMatrix[0].length; newCol++) { newMatrix[newRow][newCol]=matrix[newRow][newCol]; } } for(int row=0; row < matrix.length; row++) { for(int column = 0; column < matrix[row].length; column++) { System.out.print(matrix[row][column]+" "); } System.out.println(); } return matrix; }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

Briefly describe the basic components of any logistics system.

Answered: 1 week ago

Question

=+2. How reliable is this existing information?

Answered: 1 week ago

Question

3. Identify cultural universals in nonverbal communication.

Answered: 1 week ago

Question

2. Discuss the types of messages that are communicated nonverbally.

Answered: 1 week ago