Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / August 2006

Tip: Looking for answers? Try searching our database.

Double break out of a loop

Thread view: 
Noodle - 08 Aug 2006 05:40 GMT
Hi, I have a real easy question for you experts ;)

I want to break out of two loops...is there a way of doing this without
using flags?

eg.

while(true){
 while(true){
   break; break;
 }
}

Thanks for your help.
Knute Johnson - 08 Aug 2006 06:45 GMT
> Hi, I have a real easy question for you experts ;)
>
[quoted text clipped - 10 lines]
>
> Thanks for your help.

done: while (true) {
    while (true) {
        break done;
    }
}

Signature

Knute Johnson
email s/nospam/knute/

Lasse Reichstein Nielsen - 08 Aug 2006 06:46 GMT
> Hi, I have a real easy question for you experts ;)
>
> I want to break out of two loops...is there a way of doing this without
> using flags?

labelOfOuterLoop: while(true) {
  while(true) {
    break labelOfOuterLoop;
  }
}

The default of "break" is to end the nearest syntactically enclosing
loop. If you want to break any other enclosing statement, you have to
point out which block to break. That is done by giving the statement a
name, using a statement label, and using that name in the break.
 
/L
Signature

Lasse Reichstein Nielsen  -  lrn@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
 'Faith without judgement merely degrades the spirit divine.'

Noodle - 08 Aug 2006 07:22 GMT
> > Hi, I have a real easy question for you experts ;)
> >
[quoted text clipped - 17 lines]
>  DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
>   'Faith without judgement merely degrades the spirit divine.'

Thankyou for your responses Knute and Lasse. Thats exactly what I
wanted.

Noodle


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.