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

  • Home
  • SEARCH
  • 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 9039883
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T09:50:28+00:00 2026-06-16T09:50:28+00:00

I have got confused due to what is true regarding the operator precedence in

  • 0

I have got confused due to what is true regarding the operator precedence in Java. I read in tutorials a long time ago that AND has a higher priority than OR, which is confirmed by the answers provided in the question. However, I am currently studying Java using the “Sun Certified Programmer for Java 6 Study Guide”. This book contains the following example:

int y = 5;
int x = 2;
if ((x > 3) && (y < 2) | doStuff()) {
    System.out.println("true");
}

I am copying and citing the explanation of how the compiler handles the above code:

If (x > 3) is true, and either (y < 2) or the result of
doStuff() is true, then print "true". Because of the
short-circuit &&, the expression is evaluated as though there were
parentheses around (y < 2) | doStuff(). In other words, it is
evaluated as a single expression before the && and a single
expression after the &&.

This implies though that | has higher precedence than &&. Is it that due to the use of the “non-short-circuit OR” and instead of the short circuit OR? What is true?

  • 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-16T09:50:30+00:00Added an answer on June 16, 2026 at 9:50 am

    That’s because it is using the | operator instead of ||, which has a higher priority. Here’s the table.

    Use the || operator instead and it’ll do what you think.

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

Sidebar

Related Questions

I got completely confused with gae. I have a script, that does a post
I have the following code and got myself confused: I have a query that
I'm pretty confused. I have a point: x= -12669114.702301 y= 5561132.6760608 That I got
I got confused understanding the usage of the volatile keyword in Java. I have
There are a few concepts about iPhone memory management that have got me confused,
I have checked some tutorials but I got confused by the parameters in this
I am rather confused I have got a createuser wizard control that I use
I'm new to EF and have read some articles. After reading I got confused
I got confused with Git !! I have some files which have added and
I have a few simple questions, because I got confused reading all difference responses.

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.