| Author |
Operators =
|
Swerrgy Smith
Ranch Hand
Joined: Mar 26, 2010
Posts: 49
|
|
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: 49
|
|
OK I see how it works Thank you very much.
|
 |
 |
|
|
subject: Operators =
|
|
|