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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T02:56:13+00:00 2026-05-28T02:56:13+00:00

I was looking over some mock OCJP questions. I came across a really baffling

  • 0

I was looking over some mock OCJP questions. I came across a really baffling syntax. Here it is:

class OddStuff {
    public static void main(String[] args) {
        boolean b = false;
        System.out.println((b != b));// False
        System.out.println((b =! b));// True
    }
}

Why does the output change between != and =!?

  • 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-28T02:56:14+00:00Added an answer on May 28, 2026 at 2:56 am

    The question is just playing with you with confusing spacing.

    b != b is the usual != (not equals) comparison.

    On the other hand:

    b =! b is better written as b = !b which is parsed as:

    b = (!b)
    

    Thus it’s two operators.

    1. First invert b.
    2. Then assign it back to b.

    The assignment operator returns the assigned value. Therefore, (b =! b) evaluates to true – which is what you print out.

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

Sidebar

Related Questions

I'm looking over some code and I came across some syntax that I don't
I was looking over some code the other day and I came across: static
I've spent some time looking over other questions but I dont really understand some
While l was looking over some questions about MEF, I stumbled onto this particular
Am looking over some snippets of code and have come across a return statement
I've been looking over the Shopify API, and I've seen some really cool RESTful
I'm looking over some previous developers code and I come across this line: location.href
I am looking over some code to review and have come across a busy
Fairly straight-forward question here. Been looking over some code and I've seen a function
I have been looking all over the internet and i found some good guides

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.