Why does Java not show an error for double semicolon at the end of a statement?

As told by other answers, usually the second semicolon is interpreted as an empty statement, which is permissible where ever a statement is permissible.

Actually, there are cases where a double semicolon does produce an error:

public int method() {
   return 1;;
}

When the compiler determines that a location is not reachable (and this is defined exactly in the JLS, but includes the locations directly after a return, break, continue and throw), no statement is allowed there, not even an empty one.


Because a double semicolon is not treated as a double semicolon but as a semicolon plus an empty statement. And an empty statement, which does nothing, is not an error.