How to fix "illegal start of expression" error in Java

The "illegal start of expression" error is a compile time error when the compiler finds an inappropriate statement in the code. The java compiler, javac, compiles your source code from top to bottom, left to right and when it sees something inappropriate at the start of an expression, it throws "illegal start of expression" error. The most common reason of this is a missing semi-colon. You might know that every statement in Java ends with a semicolon, but if you forget one, you won't get an error that there is a missing semi-colon at the end of statement because the compiler doesn't know the end. When compiler checks the next statement it sees illegal start because an earlier statement was not terminated. The bad part is that you can get tens of "illegal start of expression" error by just omitting a single semi-colon or missing braces, as shown in the following example.
Read more »