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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T08:33:23+00:00 2026-05-18T08:33:23+00:00

Hi I have a question that can I use such a this code: if

  • 0

Hi
I have a question that can I use such a this code:

        if (low != mid && mid != high) {
        for (int i = 0; i <= mid; i++) {
            boolean bool = Determinate.isPointLeftSide(a, auxiliaryListTwo.get(i), auxiliaryListTwo.get(i + 1));
            if (bool == false) {
                p = auxiliaryListTwo.get(i);

            } else {
                boolean bool1 = Determinate.isPointRightSide(a, auxiliaryListTwo.get(i + 1), auxiliaryListTwo.get(i));
                boolean bool2 = Determinate.isPointRightSide(a, auxiliaryListTwo.get(i + 1), b);
                if (bool1 == true && bool2 == true) {
                    p = auxiliaryList.get(i + 1);
                }
                else{
                    i++;
                }
            }

        }

    }

I have used “i++” in the else part ,is it 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-05-18T08:33:24+00:00Added an answer on May 18, 2026 at 8:33 am

    is it correct?

    If want the code to have the effect of i = i +1, then it is correct. Since you already increment i in the for statement, i will be incremented twice if it reaches that else. As long as you have analyzed the implications of this in your code, you should be fine. In your case, you won’t have to worry about out of bounds issues because the loop at the top terminates if i<=mid and there’s no code after the i++. However, the loop will never be run for certain values of i when i++ is reached as it effectively skips an iteration.

    Here’s a quick refactoring of your code to remove useless variables. For maximum clarity, you should put the variables back but use more informative variable names, like boolean isAToTheLeftOfB = ***. Comments are your friend!!

    package example;
            if (low != mid && mid != high) {
            for (int i = 0; i <= mid; i++) {
                if ( ! Determinate.isPointLeftSide(a, auxiliaryListTwo.get(i), auxiliaryListTwo.get(i + 1))) {
                    p = auxiliaryListTwo.get(i);
    
                } else {
                    if ( Determinate.isPointRightSide(a, auxiliaryListTwo.get(i + 1), auxiliaryListTwo.get(i)) && Determinate.isPointRightSide(a, auxiliaryListTwo.get(i + 1), b) ) {
                        p = auxiliaryList.get(i + 1);
                    }
                    else{
                        i++;
                    }
                }
            }
        }
    

    EDIT: Thanks to Vladimir for pointing out that you should use the continue statement instead of incrementing the counter directly. This is definitely more clear and less error prone.

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

Sidebar

Related Questions

Following on from this question I now have code that can attach to a
I have a question that can I use AS400ConnectionPool in Spring if then pls
I have a quick question that I can't find anywhere. I am limiting my
I was hoping if anyone can answer a fundamental question that I have regarding
I have a question that is similar to this question , but mine concerns
The short question is: How can I use Visual Studio to create/compile/run projects that
I have a question regarding JavaScript and methods by which its code can be
I have javascript string variable with var sttr=We prefer questions that can be answered
I have a few questions that I hope clarity and facts can be fed
I have a question that keeps bothering me. Currently, I have started using Kohana

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.