This week's book giveaway is in the Java in General forum. We're giving away four copies of Beginning Java 17 Fundamentals: Object-Oriented Programming in Java 17 and have ishori Sharan & Adam L Davis on-line! See this thread for details.
this output 5 as after ++y ,y become 2 then add to it y++ where y =2 in that case then 2+2 =4 then increment y to be 3 then add the left hand side operands of y to have y=y+4= 3+4= 7
??? that what i understand but i don't know how 5 is the output ??
also try to test the same code changing y to int y=0; and see the result that =2
SCJP Pass 85%....
Thousands of candles can be lighted from a single candle, and the life of the candle will not be shortened
1) Precedence Order: When two operators share an operand, the operator with higher precedence goes first.. I think, you know that!
2) Associativity : When two operators with the same precedence the expression is evaluated according to its associativity.
For Ex :
is treated as
Since = operator has right to left associativity.
3) Order of evaluation : In Java, the left operand is always evaluated before the right operand. also it applies to function arguments.
For Ex :
Hope you understand this!
|BSc in Electronic Eng| |SCJP 6.0 91%| |SCWCD 5 92%|