Q:

Declare two dimensional array called Array2, Change the values of the first row by multiplying each value by two, Print all array elements using the nested for loops

0

Exercise 9: Declare two dimensional array called Array2 as following:

int[][] Array2 = {{22, 15, 21, 76}, {43, 36,}, {1, 5, 11}, {564}}

Change the values of the first row by multiplying each value by two.

Print all array elements using the nested for loops.

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

import java.util.Scanner;
public class HelloWorld
{
	public static void main(String[] args) {
	    int [][]Array2 = {{22, 15, 21, 76}, {43, 36,}, {1, 5, 11}, {564}};
	    for(int columns=0;columns<Array2[0].length;columns++)
	    {
	        Array2[0][columns]=Array2[0][columns]*2;
	    }
	    
	    //print all array elements using nested loop:
	    for(int rows=0;rows<4;rows++)
	    {
	        for(int columns=0;columns<Array2[rows].length;columns++)
	        {
	        System.out.print(Array2[rows][columns]+"    ");
	            
	        }
	        System.out.println("");
	    }
	}
}

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now