How can I tell whether or not a given integer is even or odd using java? Also, can I put an if statement within a while loop? [ November 02, 2003: Message edited by: Brandi Love ]
[Wayne]: isEven = number % 2 == 0; [Wililam]: That may be legal, but it isn't read-able. It's not? Ummm... how about now? boolean isEven = (number % 2 == 0); [Tom]: isEven = number%2==0?true:false; OK, now that one's pretty funny.
Actually writing code like this (instead of the first example) is one of the first ways to separate yourself from the newbie programmers. It is as readable as the first example, and much more concise. Perogi.
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.