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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T07:37:28+00:00 2026-06-08T07:37:28+00:00

Firstly I learnt that & , | , ^ are the bitwise operators, and

  • 0

Firstly I learnt that &, |, ^ are the bitwise operators, and now somebody mentioned them as logical operators with &&, ||, I am completely confused – the same operator has two names? There are already logical operators &&, ||, then why use &, |, ^?

  • 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-08T07:37:30+00:00Added an answer on June 8, 2026 at 7:37 am

    The Java operators &, | and ^ are EITHER bitwise operators OR logical operators … depending on the types of the operands. If the operands are integers, the operators are bitwise. If they are booleans, then the operators are logical.

    And this is not just me saying this. The JLS describes these operators this way too; see JLS 15.22.

    (This is just like + meaning EITHER addition OR string concatenation … depending on the types of the operands. Or just like a “rose” meaning either a flower or a shower attachment. Or “cat” meaning either a furry animal or a UNIX command. Words mean different things in different contexts. And this is true for the symbols used in programming languages too.)


    There are already logical operators &&, ||, why use &, |, ^?

    In the case of the first two, it is because the operators have different semantics with regards to when / whether the operands get evaluated. The two different semantics are needed in different situations; e.g.

        boolean res = str != null && str.isEmpty();
    

    versus

        boolean res = foo() & bar();  // ... if I >>need<< to call both methods.
    

    The ^ operator has no short-circuit equivalent because it simply doesn’t make sense to have one.

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

Sidebar

Related Questions

This Question arises from a Q&A here I have some doubts that i think
EDIT: I've learnt, and it's probably true that YouTube uses MySQL. But it probably
Firstly I realise that this is a familiar question, it seems to pop up
Firstly yes i know that ints are more native than bytes and that all
Firstly, I would like to say that I don't mean the full path, what
Firstly, let me say that I know that http://sphinxsearch.com/docs/current.html#conf-sql-attr-string says strings can only be
Firstly, let me just say that I'm very new to JSR-170 and Jackrabbit/Lucene in
Some time back i had installed MySQL on Windows. Firstly,I got to learn that
I've recently started to learn C++ and am completely confused with the choices of
Firstly, I want to tell you that I am a novice in rails and

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.