Semicolon in do-while

Help and support on OCA OCP Java Programmer Certification Questions
1Z0-808, 1Z0-809, 1Z0-815, 1Z0-816, 1Z0-817

Moderator: admin

Post Reply
Sweetpin2
Posts: 27
Joined: Thu Feb 07, 2013 9:46 pm
Contact:

Semicolon in do-while

Post by Sweetpin2 »

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?

Guest

Re: Semicolon in do-while

Post by Guest »

Sweetpin2 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?
as per OCA Java SE 7 Programmer I Certification Guide

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!

admin
Site Admin
Posts: 10066
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

Re: Semicolon in do-while

Post by admin »

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.

Post Reply

Who is online

Users browsing this forum: No registered users and 215 guests