case -1: foo happens here (since -1 < 0)
case 0: bar happens here (since 0 == 0)
case 1: foo happens here and bar happens here (since 1 != 0 and 1 > 0)
This code also illustrates the point:
for (int n = -1; n < 2; n++)
{
System.out.println("***************************");
System.out.println("n is now " + n);
if (n < 0 || n != 0)
System.out.println("Test 1: (n < 0 || n != 0) is true; FOO is true");
if (n >= 0)
System.out.println("Test 2: (n >=0) is true; BAR is true");
}
The code produces the following output:
***************************
n is now -1
Test 1: (n < 0 || n != 0) is true; FOO is true
***************************
n is now 0
Test 2: (n >=0) is true; BAR is true
***************************
n is now 1
Test 1: (n < 0 || n != 0) is true; FOO is true
Test 2: (n >=0) is true; BAR is true
In a message dated 11/26/2002 1:36:55 PM Central Standard Time,
[EMAIL PROTECTED] writes:
Try this. It will print "foo happens here" only when n is 0.
>
>
>However, a clearer way to code it is this:
>
> if (n >= 0)
> System.out.println("bar happens here");
> else
> System.out.println("foo happens here");
>____________________________________________________
____________________________________________________
To change your JDJList options, please visit:
http://www.sys-con.com/java/list.cfm
Be respectful! Clean up your posts before replying
____________________________________________________
