|
Do you need help with your Java programming?
Click here for instant help with your Java code. |
Empty Statements in Java
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: |
int i = 0;;;; |
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: |
for (int i = 0; i < 10; i++); |
| Previous | Next | |
Tutorial Home | ||
| Do you know your Java? | |
| Take a Ten-Question-Java-Quiz! | |
Search for code examples on this site
