I could not understand the exact computation logic here. How is 01234
being treated.
public static void main(String[] args) {
System.out.println(01234 + 43210);
System.out.println(1234 + 43210);
}
Output
43878
44444
I could not understand the exact computation logic here. How is 01234
being treated.
public static void main(String[] args) {
System.out.println(01234 + 43210);
System.out.println(1234 + 43210);
}
Output
43878
44444
A number literal starting with a leading zero is treated as octal (base 8).
So 01234
is in fact 668 (decimal)
How is 01234 being treated?
It is treated here as octal. Any number starting with 0
is octal.