Page 1 of 1

Semicolon after while in do-while statement

Posted: Tue Nov 12, 2024 5:05 am
by irateturbulent
Hello,

Is it mandatory to have the semicolon after while in do-while statement. I read it some where & it says it's not mandatory but when i don't give it i am getting compilation error.
So is there any code example to clarify my doubt?

Thanks in advance!

Re: Semicolon after while in do-while statement

Posted: Tue Nov 12, 2024 6:36 am
by admin
Did you use the command line to test? Please post the code the code that you tried and that didn't compile.

Re: Semicolon after while in do-while statement

Posted: Wed Dec 04, 2024 2:37 am
by posetinkle
Yes, the semicolon after `while` in a `do-while` statement is mandatory in Java. Without it, the code will not compile.