Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Why the ; after do...while?

807603Nov 30 2007 — edited Dec 2 2007
Does anyone know why the semicolon is required after a do while loop? This is pointless to bother us programmers to have to type a semicolon that we shouldn't need to care about. If they took this requirement out of the syntax, like Javascript and Actionscript, that would make me happy because it would just be much cleaner and also get rid of a compile check that doesn't need to exist. It would even be backward compatible because all the old code that has a semicolon would just execute an empty statement after the do...while loop. Did Java just want to copy C or something here? They should have spared us all this ugly flaw from C. Sun, please, abstract this semicolon away from us!


UGLY
do {
System.out.println("Sun, please, abstract this semicolon away from us!");
} while(true); // <-- WHY!!? ='(
BETTER ! !
do {
System.out.println("Sun, please, abstract this semicolon away from us!");
} while(true) // <-- look Sun, no semicolon! =)
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Dec 30 2007
Added on Nov 30 2007
10 comments
122 views