File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/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 Android Security Essentials Live Lessons this week in the Android 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: 88
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: 88
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
booleans
toString() Method
equality test for boolean
simple question
doubt in instanceof operator..