Computer Science, asked by akashgmgowda2002, 7 months ago

what is an array how a single dimension and two dimension arrays are declared and initialised​

Answers

Answered by hoangmustang
1

Answer:

Hello, i have done my solution but two-dimension array is hard to explain(i did some explain) so you need to do some exercises. ALL IS WRITTEN IN JAVA

package newPackage;

import java.util.*;

public class array {

public static void main(String[] args) {

 Scanner input = new Scanner(System.in);

 int [] arr = new int[10];//the one dimension array is named arr with size of 10 elements

for(int i = 0; i < arr.length; i++) {//loop through 10 times(array arr length)

arr[i] = input.nextInt();//read input from the user(initialised), we take i as the index

}

int [][] arr2 = new int[3][4];//the two dimension array is named arr2 with size 12 elements(3 * 4)

for(int j = 0; j < arr2.length; j++) {//we need nested loop because 2 dimension array is more complex

for(int k = 0; k < arr2[j].length; k++) {

 arr2[j][k] = input.nextInt();//read input from the user

}

}

}

}

Explanation:

MARK ME BRAINLIEST!

Similar questions