import java.util.Scanner;
import java.lang.*;
public class Main
{
public static void main(String[] args)
{
Scanner sc = new Scanner(System.in);
int testcase = sc.nextInt();
for(int i=0;i<testcase;i++)
{
int a = sc.nextInt();
int b= sc.nextInt();
add(a,b);
}
sc.close();
}
static void add(int a,int b)
{
int sum=0;
sum=a+b;
System.out.println(sum);
}
}
This is my code.It’s a simple addition code but I’m still getting an error.The code works perfectly fine on my Intellij but here the NZEC error occurs.
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)
Please do help if you know how to remove this error