Empty statements

You have most likely noticed that a statement in Java usually ends with a semi-colon.
If you just write a semi-colon without anything in front of it, it’ll be interpreted as an empty statement.

Consider these examples:

That was an assignment that ended with a semi-colon, followed by three empty statements.
Although the compiler allow this (most IDE’s warn about empty statements) the above example is useless, however it can be “useful” in loops if you don’t want anything to happen in the loop:

Search for more Java info on this site here:
Custom Search

Please type any questions here.