public class Test {
public static void main(String [] s) {
int x = 99999;
long y = 99999;
long res = x * x;
System.out.println("x^2 = " + res);
res = y * y;
System.out.println("y^2 = " + res);
}
}
Output:
x^2 = 1409865409
y^2 = 9999800001
I am really confused to see the output from the above code segment. I expected to get the same (correct) answer but here x^2 is actually wrong!