What does this print?
int x = 5;
System.out.println(x++ + ++x);
x++ (post-increment) uses 5 then increments x to 6; ++x (pre-increment) increments x to 7 then uses 7. So the expression evaluates to 5 + 7 = 12.
Example
int x = 5;
System.out.println(x++ + ++x); // Output: 12
Related Questions
1
JavaBeginner#puzzle#strings
What is the output of this code?
String s1 = "abc";
String s2 = "abc";
String s3 = new String("abc");
System.out.println(s1 == s2);
System.out.println(s1 == s3);