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 If condition Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "If condition" Watch "If condition" New topic
Author

If condition

asha ganapathy
Ranch Hand

Joined: Nov 03, 2006
Posts: 54
please let me know where i am going wrong
In my opinion the x value should be 2, but the answer is 4.
aslika bahini
Ranch Hand

Joined: Mar 03, 2007
Posts: 111
Hi asha,



else if(b=false){ // yes b is false here
x=2;

orginally posted by asha

here.. you are assigning b=false.

if, b == false then, it prints x = 2

regards
samura

Praveen Seluka
Ranch Hand

Joined: Jul 17, 2007
Posts: 95
Hi

The second condition
else if (b=false) is an assignment operation.It assigns b to false and then the if loop becomes false so it wont be x=2.

Thanks
Praveen SP
asha ganapathy
Ranch Hand

Joined: Nov 03, 2006
Posts: 54
ok i got it thanks a lot
 
Consider Paul's rocket mass heater.
 
subject: If condition