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; ...
Discussions

Java Input scanner to array multidimensional - Stack Overflow
I want to display an array of input that I input. and in print automatically. I want to display the array of input values ​​that I input. and will be printed automatically. my code like this : pu... More on stackoverflow.com
🌐 stackoverflow.com
Need help in Java specifically 2D Array
Show the code you’ve tried so we can give you hints to point you in the right direction or to help explain any misconceptions you have. More on reddit.com
🌐 r/learnprogramming
8
2
April 25, 2023
Write a program that inputs a 2D array and displays how the array elements will look in row major form and column major form.
Write a program that inputs a 2D array and displays how the array elements will look in row major form and column major form. More on knowledgeboat.com
🌐 knowledgeboat.com
1
11
April 3, 2023
java - Initialized a Two Dimensional Array using Scanner. When trying to display two dimensional array, array values are all nulled - Stack Overflow
I was always interested in learning an object-oriented programming language and have just got into Java. Right now I am stuck on two-dimensional arrays. I have a written a program where the user se... More on stackoverflow.com
🌐 stackoverflow.com
🌐
Learn Java
javatutoring.com › java-two-dimensional-array
Two Dimensional Array In Java – JavaTutoring
2 weeks ago - 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.
🌐
IncludeHelp
includehelp.com › java-programs › read-and-print-a-two-dimensional-array.aspx
Java program to read and print a two dimensional array
Read number of rows and columns, ... 5 6 7 8 9 Output: Matrix is: 1 2 3 4 5 6 7 8 9 · import java.util.Scanner; public class Ex2DArray { public static void main(String args[]) { // initialize here....
🌐
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 ...
🌐
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   March 14, 2026
Find elsewhere
🌐
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 ...
🌐
Scientech Easy
scientecheasy.com › home › blog › multidimensional array in java (2d array)
Multidimensional Array in Java (2D Array) - Scientech Easy
February 14, 2025 - Learn multidimensional array in java with example program, two dimensional array in java with example, how to declare and initialize 2D array
🌐
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(); } } }
🌐
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"); ...
🌐
Coderanch
coderanch.com › t › 756476 › java › array-user-input-separately
Taking 2d array user input separately (Java in General forum at Coderanch)
December 16, 2022 - , I am struggling with 2d array user input where the array is going to take row values and column values through a scanner iteration. Could anyone please help me repair my code?
🌐
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 ...
🌐
Upgrad
upgrad.com › home › tutorials › software & tech › two-dimensional array in java
Two-Dimensional Array in Java | Syntax & Example Program
September 2, 2025 - In this tutorial, you’ll learn the syntax of two-dimensional arrays in Java, how to create them, and how to use them with both primitive data types and objects. We’ll also walk through accessing elements with row-column indexing, and provide a full example program using a 2D array in Java.
🌐
Reddit
reddit.com › r/learnprogramming › need help in java specifically 2d array
r/learnprogramming on Reddit: Need help in Java specifically 2D Array
April 25, 2023 -

I'm creating a program that will sum up the outer squares(1) as well as the inner ones(2)(3).

I've already figured out how to sum up the outer boundaries. But, I can't sum up the inner boundaries.

The current dimension is 6x6 but it also needs to be flexible depending on user preference.

Can anyone help? T.T

111111
122221
123321
123321
122221
111111

🌐
Coderanch
coderanch.com › t › 422913 › java › Dimensional-array-declaration-Java
Two Dimensional array declaration in Java (Beginning Java forum at Coderanch)
It is called args. java ... NumberFormatException. You can write 2 3 4 5 6 (not at the command line) and pass that line to a Scanner, and use its hasNextInt() and nextInt() methods in a while loop to run the whole app five times, using 2 3 4 5 and 6....
🌐
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