SCJP1.4(96%)<br />A drop of ink can make millions think.
- Do not try and bend the spoon. That's impossible. Instead, only try to realize the truth. - What truth? - That there is no spoon!!!
The Inner that is named is not the true Inner.
- Do not try and bend the spoon. That's impossible. Instead, only try to realize the truth. - What truth? - That there is no spoon!!!
Looking for best practices
the '=' has a higher priority than '++'.
class MathTest {
public static void main (String [] args) {
int x = 10;
x = ++x + x++;
System.out.println(x);
}
}
You might think the output will be 21, but let�s break this down. The postfix ++ has precedence, so the right side will increment x to 11, but return 10. The left side will then increment x from 11 to 12. So the equation actually looks like x = 12 + 10, and the result is 22. The exam will likely include a few simple precedence questions like this.
- Do not try and bend the spoon. That's impossible. Instead, only try to realize the truth. - What truth? - That there is no spoon!!!
Mika Leino<br />SCJP, SCWCD
- Do not try and bend the spoon. That's impossible. Instead, only try to realize the truth. - What truth? - That there is no spoon!!!
Looking for best practices
I am not young enough to know everything. - Oscar Wilde This tiny ad thinks it knows more than Oscar:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
|