public class Solution {
public static void main(String[] args) {
int x = 2;
int y = 12;
y = x + y;
x = y - x;
y = y - x;
System.out.println(x);
System.out.println(y);
}
}
Did not understand the logic behind the display of 12 first and followed by 2.
Under discussion
Comments (1)
- Popular
- New
- Old
You must be signed in to leave a comment
Guadalupe Gagnon
16 February 2019, 18:16
int x = 2;
int y = 12;
y = x + y; < y = 2 + 12 : y now equals 14
x = y - x; < x = 14 - 2 : x now equals 12
y = y - x; < y = 14 - 12 : y now equals 2
System.out.println(x); < outputs x which is 12
System.out.println(y); < outputs y which is 2
0