Ask a Question
Ask Question Login
Corporate Training
  1. Community
  2. Java
  3. Question
Java

Should I remove the labels in java Or not?

Asked by Kudo Taniguchi Oct 10, 2022 985 views 1 answer
Share

About this question

So I've been writing a program and I have some indented Loops and statements and I need to BREAK multiple on command. Rather than having a load of boolean variables and if(!) BREAK; statements throughout these loops and statements, what is everyone's opinion on using labels to break them using the BREAK

e.g.

 for(...) {
     indented_example_loops:     // Label name
           for(...) {
                for(...) {
                     if(match) break indented_example_loops;
                     // ^ Break statement to break the 2 for loops at once
                }
           }
 }

Perfectly okay? Okay to do it occasionally? Completely avoid?


Your answer

1 Answer

More Java discussions

Learn & Explore

Free tutorials and interview questions from industry experts — learn the skill, then get ready to prove it.

Latest Java Blogs

Guides, tips and career advice on Java from JanBask experts.