NZEC Error in Java Code problem DRGHTS

I had written the code of DRGHTS in Java. But I couldn’t get why I am getting NZEC error in the solution. The Question code is

When I re-wrote the same code in C++ by just changing the data structures it got accepted in the first attempt. My solution link of Java is this.

@vineetpaliwal , @betlista and @junior94 Could you please help me out.

I did a quick check, but found nothing, will look at it later more. Do not use out.close(), but this was not the only problem…