aspose file tools*
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


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Operators =" Watch "Operators =" New topic
Author

Operators =

Swerrgy Smith
Ranch Hand

Joined: Mar 26, 2010
Posts: 84
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


OCPJP 6
Diana Sule
Greenhorn

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: 84
OK I see how it works Thank you very much.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Operators =
 
Similar Threads
simple question
booleans
equality test for boolean
doubt in instanceof operator..
toString() Method