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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T23:45:26+00:00 2026-05-22T23:45:26+00:00

Possible Duplicates: logical operators in java What's the difference between | and || in

  • 0

Possible Duplicates:
logical operators in java
What's the difference between | and || in Java?

As the title says, I need to know the difference between & operator and && operator.
Can anyone help me in simple words.

  1. How do they differ from each other?
  2. And which one to be used in a IF statement?
  • 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-22T23:45:28+00:00Added an answer on May 22, 2026 at 11:45 pm

    There are in fact three “and” operators:

    • a && b, with a and b being boolean: evaluate a. If true, evaluate b. If true, result is true. Otherwise, result is false. (I.e. b is not evaluated if a is not true.)
    • a & b, with a and b being boolean: evaluate both, do logical and (i.e. true only if both are true).
    • a & b, where a and b are both integral types (int, long, short, char, byte): evaluate a and b, and do a bitwise AND.

    The second one can be viewed as a special type of the third one, if one sees boolean as a one-bit integral type 😉

    As the top-level condition of an if-statement you can use the first two, but the first one is most likely useful. (I.e. there are not many cases where you really need the second and the first would do something wrong, but the other way around is more common. In most cases the first is simply a little bit faster.)

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

Sidebar

Related Questions

Possible Duplicates: What's the difference between | and || in Java? Difference in &
Possible Duplicates: Java String.equals versus == whats the difference between ".equals and ==" public
Possible Duplicates: In Javascript, what does it mean when there is a logical operator
Possible Duplicate: What is the diffference between the | and || or operators? Logical
Possible Duplicate: What is the difference between logical and conditional AND, OR in C#?
Possible Duplicates: *.h or *.hpp for your class definitions What is the difference between
Possible Duplicate: The written versions of the logical operators. I notice that C++ define
Possible Duplicates: What is the best approach for a Java developer to learn C++
Possible Duplicate: In Javascript, what does it mean when there is a logical operator
Possible Duplicates: Declaring pointers; asterisk on the left or right of the space between

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.