View Single Post
Old Jul 28th, 2007, 4:36 AM   #12
357mag
Hobbyist Programmer
 
Join Date: Mar 2005
Posts: 148
Rep Power: 4 357mag is on a distinguished road
Kinda confusing. In C++ any non-zero integer means true, and zero means false. I think I did read in one of my books about Java that in Java the zero does not mean false and any non-zero integer does not necessarily mean true. I thought the if statement always tests for truth. So if I did this in Java:

int x = 1;

if (x)
   System.out.print("Welcome home.");

else
   System.out.print("Go away.");

That would be wrong? I would have to say:

int x = 1;

if (x == 1)
   System.out.print("Welcome home.");

else
   System.out.print("Go away.");

I'm going to have to play around with this stuff.
357mag is offline   Reply With Quote