Solved

goto

Posted on 2004-08-17
5
439 Views
Last Modified: 2010-03-31
Hi experts,
I know in other languages you can mark some position in a for loop for example and use a goto when needed. Is there anything like this in java and please include an example.
also does break exit the loop entirely?
what does continue do?

thanks
0
Comment
Question by:Samooramad
  • 3
5 Comments
 
LVL 35

Accepted Solution

by:
girionis earned 125 total points
ID: 11821196
Java has a goto statement also but it is not (yet) supported, although it is a reserved word: http://java.sun.com/docs/books/tutorial/java/nutsandbolts/flow.html

You might as well use the continue statement instead: http://java.sun.com/docs/books/tutorial/java/nutsandbolts/branch.html
0
 
LVL 35

Expert Comment

by:girionis
ID: 11821207
Or a labeled break maybe, take a look at the link I posted above.
0
 
LVL 4

Assisted Solution

by:hamood
hamood earned 125 total points
ID: 11821265
java do not have goto statement

break statement will break the look i.e exit the loog without completing it.

continue will skip the statement after continue keywork, increment the loop counter and start execute the loop again

hamood
0
 

Author Comment

by:Samooramad
ID: 11821315
ok thanks!
0
 
LVL 35

Expert Comment

by:girionis
ID: 11821351
:)
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now