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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T11:58:40+00:00 2026-06-03T11:58:40+00:00

Does the order of operands in a Boolean affect the order of evaluation? As

  • 0

Does the order of operands in a Boolean affect the order of evaluation? As an example can I rely on

String s = ...;
if (s != null && s.length() > 10) ...

I seem to remember that the Java language does not define order of evaluation and that a null value of s could cause a NPE. Is this still true (a) in principle and (b) in practice with the common Java implementations?

UPDATE:
I couldn’t find the exact duplicate. It’s interesting to see the differences of opinions in the answers and get a downvote for it – ah well!

  • 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-03T11:58:41+00:00Added an answer on June 3, 2026 at 11:58 am

    Yes, it does matter and

    … the Java language does not define order of evaluation

    is not true. The arguments are evaluated from left to right, so an expression like s != null && s.length() > 10 will never throw a NullPointerException.

    See 15.7 Expressions – Evaluation Order in the Java Language Specification.

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

Sidebar

Related Questions

Does the order in which parameters are passed to a stored procedure affect the
The evaluation order does matter a lot, so, is this something called non-referential-transparency? int
My js code does POST order.php?order[]=1&order[]=2&order[]=3&order[]=4&order[]=5&&action=update How to reverse it to order.php?order[]=5&order[]=4&order[]=3&order[]=2&order[]=1&&action=update ? JavaScript:
In mysql, does the order of the WHERE clauses affect the time that it
Does the order of the column types in your database have any affect on
Does the order of conditions in there where clause affect the speed of the
Possible Duplicate: In what order does evaluation of post-increment operator happen? Consider the following
Possible Duplicate: Why does the order of the loops affect performance when iterating over
I want to write a LINQ to Entity query which does order by ascending
According to the Puppet documentation: Order does not matter in a declarative language. If

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.