File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Operators = Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Operators =" Watch "Operators =" New topic

Operators =

Swerrgy Smith
Ranch Hand

Joined: Mar 26, 2010
Posts: 91
Hi all,

In the book of Kathy and Bert, there is a piece of code that I don't understand.

Could any one explain why when we test (b = true) then the line "b is is true" is printed. But when we change to (b = false) then the line "b is false" is printed???

Thank you.
Seema Kekre
Ranch Hand

Joined: Dec 02, 2010
Posts: 35
b= true is not just a test but an assignment, b is being assigned a new value true and then it is tested for if. If it was b==true that would have been just a test

Diana Sule

Joined: Nov 08, 2010
Posts: 21
Yes, for booleans the if will test the value of the assingment.

OCPJCP 6.0 | OCPJWCD 5 | SpringSource Certified Spring Professional - Spring 3.0
Swerrgy Smith
Ranch Hand

Joined: Mar 26, 2010
Posts: 91
OK I see how it works Thank you very much.
I agree. Here's the link:
subject: Operators =
It's not a secret anymore!