Advertisement
Guest User

Untitled

a guest
Feb 21st, 2019
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.64 KB | None | 0 0
  1. public class Increment {
  2. public static void main(String[] args) {
  3. int x = 3;
  4. int y = ++x * 5 / x-- + --x;
  5. /**
  6. * x is incremented and returned to the expression which is multiplied by 5
  7. * int y = 4 * 5 / x-- + --x; (x assigned value of 4)
  8. * x is decremented, but the original value of 4 is used in the expression
  9. * int y = 4 * 5 / 4 + --x; (x assigned value of 3)
  10. * final assignment of x reduces the value to 2
  11. * int y = 4 * 5 / 4 + 2; x assigned value of 2
  12. */
  13. System.out.println("x is " + x);
  14. System.out.println("y is " + y);
  15. }
  16. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement