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:9)
WHENEVER I RUN MY PROGRAM, THESE ERRORS COME RIGHT BEHIND.
THE PROGRAM I RUN IS
:
import java.util.*;
public class Main
{
public static void main(String[] args) {
System.out.println(“Hello World”);
Scanner scn=new Scanner(System.in);
int n=scn.nextInt();
for(int row=1;row<=n;row++)
{
for(int col=1;col<=row;col++)
{
if(row==col || col==1)
{
System.out.print(row-1);
}
else
System.out.print(“0”);
}
System.out.println();
}
}
}