Hello, OnlineGDB Q&A section lets you put your programming query to fellow community users. Asking a solution for whole assignment is strictly not allowed. You may ask for help where you are stuck. Try to add as much information as possible so that fellow users can know about your problem statement easily.

How do you use goto in Java?

+1 vote
asked Sep 28, 2018 by Patrick Stock (130 points)
I don't know how goto works at all and I know I'm not supposed to use it, but it seems more convenient (If it works how I think it does) than writing more code just to go back to the beginning of the program or to a certain point in the program. It seems much easier just to "go to" that section of the code.

2 Answers

0 votes
answered Oct 1, 2018 by Shane Such (860 points)
tsk tsk that's not a good practice, don't use breaks or goto but if you do. (my tip is to look online)
0 votes
answered Apr 9, 2019 by zemiak (490 points)
there is not goto in java, you need not use it, use eg call method again in loop instead.
But tere is labels for break and continue useful in nested loops

name:              // label name
for (..
    for (...
         if (found)
             break name;

Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and and receive answers from other members of the community.