Reached end of file while parsing

how to fix java Reached end of file while parsing error
The error Reached End of File While Parsing is a compiler error and almost always means that your curly parenthesis are not ending completely or maybe there could be extra parenthesis in the end.
if (condition){ { // This doesn't close the code block

Correct way:

if (condition){ // your code goes here }
Every opening braces { needs one closing braces }. The only purpose of the extra braces is to provide scope-limit . If you put curly braces in the wrong places or omit curly braces where the braces should be, your program probably won't work at all. Moreover, If you don't indent lines of code in an informative manner , your program will still work correctly, but neither you nor any other programmer will be able to figure out what you were thinking when you wrote the code.

How to avoid this error?

java netbeans eclipse ide Because this error is both common and easily avoided , using a code editor like NetBeans or Eclipse . Using these IDE's, you can autoformat your code by pressing Alt+Shift+F . This will indent your code properly and align matching braces with the control structure (loop, if, method, class) that they belong to. This will make it easier for you to see where you're missing a matching brace .

Curly Braces in Java

The { symbol is used to denote the start of a block statement. This accounts for all the uses of { with if statements , while loops, for loops, do ... while loops, switch statements, etc.
if (a == 0) { //your statements }
In the context of a method or type ( class/interface/enum/annotation ), the { symbol is used to denote the beginning of the body of a class or a method :
public class MyClass { ... public void myMethod() { ... } }
It can also be used inside a class to declare an initializer or static initializer block:
class StaticClass() { static int a; static { a = myStaticMethod(); } };
In the case of an array literal , the { symbol is used to denote the beginning of the list of elements used inside that literal :
int[] myArr = new int[] {1, 2, 3};

reached { symbol
You can find that from above examples, each of these uses of the open brace symbol is different from all the others.