codeChallenge/MatrixInput.java
2024-10-08 05:45:58 -04:00

31 lines
765 B
Java

import java.util.ArrayList;
import java.util.Scanner;
/**
* MatrixInput
*/
public class MatrixInput {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.println("Please enter the 2D Array here: ");
System.out.println("Numbers of rows: ");
int rows = sc.nextInt();
System.out.println("Numbers of columns: ");
int columns = sc.nextInt();
int[][] arr = new int[rows][columns];
for (int i = 0; i < rows; i++) {
for (int j = 0; j < columns; j++) {
arr[i][j] = sc.nextInt();
}
}
System.out.println("");
for (int i = 0; i < rows; i++) {
for (int j = 0; j < columns; j++) {
System.out.print(arr[i][j]);
}
System.out.println();
}
}
}