The code I've written to scan in a 2d array can be seen below, im having runtime issues this is the output:
Runtime Error
Exception in thread "main" java.util.InputMismatchException: For input string: "00000000100000000000"
at java.util.Scanner.nextInt(Scanner.java:2123)
at java.util.Scanner.nextInt(Scanner.java:2076)
at Main.main(Main.java:17)
Code:
import java.util.Scanner;
public class Main
{
public static void main(String args[])
{
final int m = 20; // Rows
final int n = 20; // Columns
Scanner s1 = new Scanner(System.in);
int num = s1.nextInt();
int myArray1[][] = new int[m][n];
for (int i = 0; i < m; i++)
{
for (int j = 0; j < n; j++)
{
myArray1[i][j] = s1.nextInt();
}
}
for (int i = 0; i < m; i++)
{
for (int j = 0; j < n; j++)
{
System.out.print(myArray1[i][j] + "");
}
}
}
}
If someone could help me out i'd really appreciate it!
this input is:
00000000000000000000
00000000000000000000
00000000010000000000
00000000010000000000
00000000000000000000
00000000000000000000