Hi,
I have a doubbt in the following code
public class chaptwo
{
public static void main(
String args[])
{
int i = 0, j = 1;
if ((i++ == 1) && (j++ == 2)) {
i = 42;
}
System.out.println("i = " + i + ", j = " + j);
}
}
The answer is i =1, j= 1
Why isn't i = 42 ?
I thought this is similar to the following code
public class chaptwo
{
public static void main(String args[])
{
int i =0;
i = i++;
System.out.println("i = " + i);
}
}
where i = 0
Please explain.
Thank you