Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 875903
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T11:20:58+00:00 2026-05-15T11:20:58+00:00

I was recently coding a small java program (as design for an 8086 Assembler

  • 0

I was recently coding a small java program (as design for an 8086 Assembler program) and I wound up in an interesting position — I needed to exit out of a while loop from an inner switch-statement, something like this (pseudocode, obviously):

:MyLoop
While(foo)
    switch (bar)
       case '1': print '1'; break
       case '0': print '0'; break
       case ';': end while loop;

It seemed like the perfect place for a goto statement because a single “break” would only exit the switch statement,(especially considering that I was designing for assembly) but Java has no gotos!

I found instead that Java has something called a multi-level break, so by using “break MyLoop”, the program would break out of both the switch case and the while loop. ‘

My question then — is this an appropriate use of a multi-level break? If, for some reason, I wanted to keep the switch (instead of, say, nested else ifs) statement, is there an alternative way to mimic a multi-level break via “break” or “continue” alone?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T11:20:58+00:00Added an answer on May 15, 2026 at 11:20 am

    Personally I would usually regard this as a hint to refactor the loop into its own method – then you can return from the whole method instead of just breaking out of the loop.

    I personally find that clearer in most cases – but otherwise, this is exactly the kind of thing that labeled breaks are there for. It’s generally cleaner (IMO) than having a separate boolean variable indicating whether or not to continue the loop.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have Java experience and recently am doing some C++ coding. My question is
I've recently been coding a lot in both Objective C while also working on
I've done a bunch of Java coding recently and have got used to very
I've recently begun coding in Java in the past few months. I have a
I have always been coding in java and have recently started coding in javascript
I have recently ventured out into dealing with audio and video related coding and
I recently found out about livecoding where someone will program something on the fly
I've recently started coding in C++, but I have long time writing in C.
HI people I recently changed to VIM for coding in C. I'd like to
I've recently been learning vb.net, coming from a background in java and c. I'm

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.