Posted on 2004-08-17
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?

Question by:Samooramad
  • 3
LVL 35

Accepted Solution

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:

You might as well use the continue statement instead:
LVL 35

Expert Comment

ID: 11821207
Or a labeled break maybe, take a look at the link I posted above.

Assisted Solution

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


Author Comment

ID: 11821315
ok thanks!
LVL 35

Expert Comment

ID: 11821351

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Way to decrease size of apk file 9 104
printf performancy 11 84
Html Table Looping (part 2) 5 34
Java Inheritance super keyword use 8 32
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…
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…

735 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