Solved

goto

Posted on 2004-08-17
5
442 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 Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone 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

Suggested Solutions

Title # Comments Views Activity
Apps blocked by Java 9 88
more than one jdk and one jre 1 50
iterator/ListIterator approach 17 39
Java class and jar 3 25
An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:

829 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