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 8016713
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T20:37:00+00:00 2026-06-04T20:37:00+00:00

So basically given the below code. When action = 2; and mode = 1

  • 0

So basically given the below code.

When action = 2; and mode = 1 Will i ever be set to 2?

I am working on a colleagues code, and it is written like this, but I thought that break would just skip the if and continue the rest of case 2. So basically the if statement is pointless.

switch(action){

   case 1: i = 1; break;

   case 2: if(mode == 1)
           {
              break;
           }

           i = 2;
           break;

   case 3: i = 3; break;

Ive rewritten this as:

 case 2: if(mode != 1)
            i = 2;
         break;

But it is not the only place, and some more complex. If im going to refactor it I need some info that I am correct.

  • 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-06-04T20:37:01+00:00Added an answer on June 4, 2026 at 8:37 pm

    JLS section 14.15:

    A break statement transfers control out of an enclosing statement.

    BreakStatement:

       break Identifieropt ;
    

    A break statement with no label attempts to transfer control to the innermost enclosing switch, while, do, or for statement (emphasis added) of the immediately enclosing method or initializer block; this statement, which is called the break target, then immediately completes normally.

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

Sidebar

Related Questions

Basically, I am creating a dynamic 2d ArrayList. private ArrayList<char[]> myArray; This code below
Basically, I would like to decode a given HTML document, and replace all special
I am basically trying to combine code from two examples given in the DataTables
Basically i'd like to allow an arbitrary (but not empty ) number of key-value
I have checked similarly named questions, but they don't answer this use case. Basically,
Below I have some code which basically animates a div from the bottom of
I recently came across this in some code - basically someone trying to create
I am totally 100% stuck on this, no answer ever given for timezone support
This piece of code below is causing my app to crash EDIT @interface termsAndConditions
Basically i just want to do an arbitrary operation using given arguments of arbitrary

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.