Solved

goto

Posted on 2004-08-17
5
445 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Viewers learn about the “while” loop and how to utilize it correctly in Java. Additionally, viewers begin exploring how to include conditional statements within a while loop and avoid an endless loop. Define While Loop: Basic Example: Explanatio…
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 …
Suggested Courses

739 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