This week's book giveaway is in the OCPJP forum.
We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes need help for the 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 » Java » Beginning Java
Bookmark "need help for the If condition." Watch "need help for the If condition." New topic
Author

need help for the If condition.

Joy Vergis
Ranch Hand

Joined: Sep 14, 2009
Posts: 45
Hi,


I get the output for the below program as
The value of a:0




The default value for int types is 0. So why i get output for only a.
Mohamed Sanaulla
Saloon Keeper

Joined: Sep 08, 2007
Posts: 3071
    
  33

Did you notice in your program- Both the statements print the same message


Mohamed Sanaulla | My Blog
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19725
    
  20

a and b are both 0. That means that a<b is false, so the else statement is executed. And although you're printing the value of b (0) you say it's the value of a. Just check the String.>


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Adrabi Abderrahim
Greenhorn

Joined: Jan 23, 2011
Posts: 8

hello,

Change "a" in line 9 to "b" :

to
 
Consider Paul's rocket mass heater.
 
subject: need help for the If condition.