I am solving the very first question in Easy Section(Problem Code: TEST), I know it is silly but I am unable to solve this question.
NZEC exception (NoSuchElementException)is showing up
and sometimes it shows the main method is missing
the code is here:
/* package codechef; // don’t place package name! */
import java.util.;
import java.lang.;
import java.io.*;
/* Name of the class has to be “Main” only if the class is public. */
public class Main
{
public static void main (String[] args) throws java.lang.Exception
{
Scanner sc = new Scanner(System.in);
int num;
while(true){
num = sc.nextInt();
if(num!=42){
System.out.println(num);
}
else{
break;
}
}
sc.close();
}
}