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 Main.main(Main.java:5)
how can i resolve this error
code is
import java.util.*;
public class Main {
public static void main(String args[]) {
Scanner scn= new Scanner(System.in);
int n= scn.nextInt();
int nst=1;
int nzo=1;
int row=1;
int val=1;
while(row<=n)
{
int col=1;
while(col<=nst)
{
System.out.print(val);
col++;
}
if(row>=3)
{
for(int i=1;i<=nzo;i++)
{
System.out.print("0");
}
nzo++;
}
if(row>=2)
{
int co=1;
while(co<=nst)
{
System.out.print(val);
co++;
}}
if(row>=2)
{
val++;
}
row++;
System.out.println();
}
}
}