How to get rid of getting NZEC error while submitting solution in java?

I use this try catch method but although this method removes NZEC , it does not provide any solution at all .Please resolve this issue someone.

Thanks, itā€™s working now. I guess javaā€™s still tryna catch itself!

Watch my detailed video on NZEC error, 100% your problem will be solved!!
Click here to watch video

yeah both the answers are coming as wrong, it is very weird.

This post was flagged by the community and is temporarily hidden.

am too not able to submit my java codeā€¦getting NZEC error
I used try catch and fast I/O methods too

Before using nextInt() , use sc.hasNext()
inside if and true accept input and initialise every variable with default values

For example
int g = 0
if( sc.hasNext())
{
g = sc.nextInt();
}
// proceed using g

thanks! @manvi_03 the first one worked!

1 Like

It helpedā€¦man

Yaa ā€¦ U are correct

mine also same problemā€¦But it not getting right after using this **


** command

IN JAVA,
if ur error is in line where u take input then try in this format ,

Scanner sc=new Scanner(System.in);
int takingInput=0; 
if(sc.hasNextInt()){
takingInput= sc.nextInt();
}