Given the following sample:
public class Main { public static void main(String[] args) { System.out.println(1234); System.out.println(01234); } }
The Output is:
1234 668
Why?
This is because integer literals with a leading zero are octal integers (base 8):
1 * 8^3 + 2 * 8^2 + 3 * 8 + 4 = 668
1.4m articles
1.4m replys
5 comments
57.0k users