I think you are creating an array of wrong bounds- instead of int [][] list=new int [2][mo] there should be int [][] list=new int [mo][2]; ,because for every module you have marks of first and second assignment, am I right?

Answer from The_Long_Distance_Runner on Stack Overflow
🌐
GitHub
gist.github.com β€Ί eMahtab β€Ί 297419cb805fe93346c0
Java program to take 2D array as input from user. Β· GitHub
June 11, 2019 - import java.util.Scanner; public class Multidimensional_Arrays { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int flates[][] = new int[2][3]; System.out.println("Enter array elements = "); for (int i = 0; i < flates.length; i++) { for (int j = 0; j <= flates.length; j++) { flates[i][j] = sc.nextInt(); System.out.print(flates[i][j] + " "); } } System.out.println(); //reverse System.out.println("Reverse of Multi-dimensional Array"); for (int i = flates.length - 1; i >= 0; i--) { for (int j = flates.length; j >= 0; j--) { System.out.print(flates[i][j] + " "); } } } }
🌐
Dremendo
dremendo.com β€Ί java-programming-tutorial β€Ί java-two-dimensional-array
Two Dimensional Array in Java Programming | Dremendo
Program to input numbers in a 3x3 Matrix and display the numbers in a table format. import java.util.Scanner; public class Example { public static void main(String args[]) { int a[][]=new int[3][3]; Scanner sc=new Scanner(System.in); int r,c; ...
🌐
IncludeHelp
includehelp.com β€Ί java-programs β€Ί read-and-print-a-two-dimensional-array.aspx
Java program to read and print a two dimensional array
December 23, 2023 - System.out.print("Enter row for ... scan.nextInt(); // enter array elements. System.out.println("Enter " + (row * col) + " Array Elements : "); for (i = 0; i < row; i++) { for (j = 0; j < col; j++) { arr[i][j] = scan.nextInt(); } } // the 2D array is here....
🌐
GeeksforGeeks
geeksforgeeks.org β€Ί java β€Ί multidimensional-arrays-in-java
Java Multi-Dimensional Arrays - GeeksforGeeks
Then print the multi-dimensional array and close the scanner object. Example: Java program to demonstrate how to create Two Dimensional Array with User input.
Published Β  May 4, 2026
🌐
Learn Java
javatutoring.com β€Ί java-two-dimensional-array
Two Dimensional Array In Java – JavaTutoring
May 26, 2026 - 2) To print the two-dimensional array, for loop iterates from o to i<3 for loop iterates from j=0 to j<2 print the element which is at the index a[i][j]. ... Read the row length, column length of an array using sc.nextInt() method of Scanner class.
🌐
YouTube
youtube.com β€Ί coding wallah sir
Two Dimensional Array in Java Using Scanner | Initialize Two Dimensional Array in Java - YouTube
Hi in this video we will learn about How to take user input in Two-Dimensional Array in Java Using Scanner βž–βž–βž–βž–βž–βž–βž–βž–βž–βž–βž–βž–βž–βž–βž–βž–βž–βž–βž–βž–βž–βž–πŸ™‹πŸΌβ€β™‚οΈHello All Kaise Ho Sa...
Published Β  March 25, 2021
Views Β  1K
🌐
Tutorjoes
tutorjoes.in β€Ί Java_example_programs β€Ί read_and_print_a_two_dimensional_array_in_java
Write a program to Read and print a Two Dimensional array
import java.util.Scanner; public class Read_Print { public static void main(String args[]) { Scanner input = new Scanner(System.in); int a[][] = new int[100][100]; int row, col, i, j; System.out.print("Enter Number of Rows : "); row = input.nextInt(); System.out.print("Enter Number of Columns : "); col = input.nextInt(); for (i = 0; i < row; i++) { for (j = 0; j < col; j++) { System.out.printf("Enter Array Elements a[%d][%d] :",i,j); a[i][j] = input.nextInt(); } } System.out.println("Display 2D Array Element is : "); for (i = 0; i < row; i++) { for (j = 0; j < col; j++) { System.out.print(a[i][j] + " "); } System.out.println(); } } }
Find elsewhere
🌐
Java67
java67.com β€Ί 2014 β€Ί 10 β€Ί how-to-create-and-initialize-two-dimensional-array-java-example.html
How to declare and Initialize two dimensional Array in Java with Example | Java67
The program should: initialize the array to 0 input values print the contents of the array in a matrix format.Delete ... ellow can you code this.. this is the output Please enter the grade of student 1 Q1;81 Q2;91 Q3;91 Please enter the grade ...
🌐
Wyzant
wyzant.com β€Ί resources β€Ί ask an expert
Sort a double dimensional array in java using scanner class. | Wyzant Ask An Expert
April 8, 2021 - if you already know the size of original 2D matrix, create a 1D array first, then use Scanner to input the matrix from console line by line, and store the value into 1D array. once input finished, use Arrays.sort(array) to sort the 1D array, then print it out per 2D format. if the size of original ...
🌐
Blogoncode
blogoncode.com β€Ί 2022 β€Ί 11 β€Ί take-user-input-in-java-2d-array.html
How to Take User Input in Java 2D Array using Scanner | Create and Insert 2D Array
For taking user input, we have ... user inputs into array. import java.util.Scanner; public class TwoDimensionalArray { public static void main(String[] args) { Scanner sc = new Scanner(System.in); // Taking row and column size ...
🌐
GeeksforGeeks
geeksforgeeks.org β€Ί java β€Ί how-to-take-array-input-from-user-in-java
How to Take Array Input From User in Java? - GeeksforGeeks
July 23, 2025 - ... // Java program to take 2D array input from the user // Using Scanner class and loops import java.util.Scanner; public class Geeks { public static void main(String[] args) { Scanner sc = new Scanner(System.in); // Prompt the user for the ...
🌐
Kosbie
kosbie.net β€Ί cmu β€Ί fall-08 β€Ί 15-100 β€Ί handouts β€Ί notes-two-dimensional-arrays.html
Two-Dimensional Arrays
import java.util.*; class MyCode { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); System.out.print("Enter # of rows: "); int rows = scanner.nextInt(); System.out.print("Enter # of cols: "); int cols = scanner.nextInt(); int[][] a = new int[rows][cols]; System.out.print("Enter " + rows + "x" + cols + "=" + (rows*cols) + " integers: "); for (int i=0; i<rows; i++) for (int j=0; j<cols; j++) a[i][j] = scanner.nextInt(); System.out.println("Here are those " + (rows*cols) +" integers in a " + rows + "x" + cols + " 2d-array:"); System.out.println(Arrays.deepToStrin
🌐
BeginnersBook
beginnersbook.com β€Ί 2024 β€Ί 06 β€Ί how-to-take-array-input-in-java
How to take array input in Java
The approach is similar here, however in order to take 2D array inputs, we need to use the nested for loop. Also, we need additional row and column inputs from user. import java.util.Scanner; public class TwoDArrayInputExample { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); System.out.print("Enter the number of rows: "); int rows = scanner.nextInt(); System.out.print("Enter the number of columns: "); int cols = scanner.nextInt(); int[][] array = new int[rows][cols]; System.out.println("Enter the elements of the array:"); for (int i = 0; i < rows; i++) { for
🌐
Stack Overflow
stackoverflow.com β€Ί questions β€Ί 52909506 β€Ί initialized-a-two-dimensional-array-using-scanner-when-trying-to-display-two-di
java - Initialized a Two Dimensional Array using Scanner. When trying to display two dimensional array, array values are all nulled - Stack Overflow
public class TwoDimensionalArrays { public static void main(String[] args) { displayTwoDimensionalArray(firstTwoDimensionalArray); int secondTwoDimensionalArray[][] = new int[4][3]; initTwoDimensionalArray(secondTwoDimensionalArray); displayTwoDimensionalArray(secondTwoDimensionalArray); } public static void displayTwoDimensionalArray(int x[][]) { for(int row = 0; row < x.length; row++) { for(int col = 0; col < x[row].length; col++) { System.out.print(x[row][col] + "\t"); } System.out.println(); } System.out.println(); } public static void initTwoDimensionalArray(int x[][]) { Scanner scan = ne
🌐
Blogger
javarevisited.blogspot.com β€Ί 2016 β€Ί 07 β€Ί how-to-take-array-input-in-java-using-Scanner-Example.html
How to take array input from command line in Java ? Scanner Example
April 2, 2025 - Now, let's see the output of this program to understand how to take array as input from command line in Java: Output Please enter length of String array 3 Please enter array elements Java C++ Ruby The String array input from user is : [Java, C++, Ruby] Please enter number of rows and columns of 2D array 2 3 Please enter array elements row by row 1 2 3 4 5 6 The 2d int array input from user is : [[1, 2, 3], [4, 5, 6]] You can see that we have successfully taken array input from the user, both String and integer array, and both one and a two-dimensional array. Don't forget to close the Scanner once you have done to prevent resource leaks in Java, you can also see these Java programming courses to learn more about why you should close readers and stream once you are done using them.
🌐
w3resource
w3resource.com β€Ί java-exercises β€Ί basic β€Ί java-basic-exercise-155.php
Java - Change the rows and columns of a 2-dimension array
February 2, 2026 - Original Array: 10 20 30 40 50 ... void main(String[] args) { // Initializing a 2D array with values int[][] twodm = { {10, 20, 30}, {40, 50, 60} }; // Displaying the original array System.out.print("Original Array:\n"); ...