Hi,
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?
Semicolon in do-while
Moderator: admin
-
- Posts: 27
- Joined: Thu Feb 07, 2013 9:46 pm
- Contact:
Re: Semicolon in do-while
as per OCA Java SE 7 Programmer I Certification GuideSweetpin2 wrote:Hi,
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?
NOTE: Don’t forget to use a semicolon (;) to end the do-while loop, after specifying its condition. Even some of the experienced programmers overlook it!
-
- Site Admin
- Posts: 10066
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: Semicolon in do-while
Yes, it is mandatory as per http://docs.oracle.com/javase/specs/jls ... #jls-14.13
DoStatement:
do Statement while ( Expression ) ;
If you like our products and services, please help us by posting your review here.
Who is online
Users browsing this forum: No registered users and 211 guests