Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Increment {
- public static void main(String[] args) {
- int x = 3;
- int y = ++x * 5 / x-- + --x;
- /**
- * x is incremented and returned to the expression which is multiplied by 5
- * int y = 4 * 5 / x-- + --x; (x assigned value of 4)
- * x is decremented, but the original value of 4 is used in the expression
- * int y = 4 * 5 / 4 + --x; (x assigned value of 3)
- * final assignment of x reduces the value to 2
- * int y = 4 * 5 / 4 + 2; x assigned value of 2
- */
- System.out.println("x is " + x);
- System.out.println("y is " + y);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement