program to input 2d array using Scanner
class but output shows:
Runtime error:
NZEC
Exception in thread "main" java.util.NoSuchElementException
at java.util.Scanner.throwFor(Scanner.java:862)
at java.util.Scanner.next(Scanner.java:1485)
at java.util.Scanner.nextInt(Scanner.java:2117)
at java.util.Scanner.nextInt(Scanner.java:2076)
at Wocode.main(Main.java:9)
Code snippet:
import java.lang.*;
import java.util.*;
import java.util.Scanner;
class Wocode {
public static void main(String args[]) {
Scanner s=new Scanner(System.in);
int m=s.nextInt();
int n=s.nextInt();
int A[][] = new int[m][n];
for(int i=0;i<m;i++)
{
for(int j=0;j<n;j++)
{
A[i][j]=s.nextInt();
}
}
}
}