+ 1

(Java) what happens when we declare an int and assign it a value which start with 0?

For example: int a = 065; System.out.println(a) Why output is 53?

9th Oct 2019, 9:14 PM
Federico Riva
2 ответов
+ 7
When you write zero in front of a number, then the number is treated as octal number. 065octal = 6*8^1 + 5*8^0 = 53decimal
9th Oct 2019, 9:19 PM
voja
voja - avatar
+ 2
voja thanks now I understand
9th Oct 2019, 9:21 PM
Federico Riva