+ 1

What does this mean?

The above code gives output 8,when initialized with 010. anyone pls explain this? public class Program { public static void main(String[] args) { int a=010; System.out.println(a); } }

15th Mar 2017, 3:43 PM
Manideep Yadav
Manideep Yadav - avatar
3 Answers
+ 2
02 will save 2 to the variable and 8 should go for next input so in my opinion the output should be just 2 . I had tried this with arrays and it stores values in different array members .
16th Mar 2017, 4:30 PM
Sahaj Bamba
Sahaj Bamba - avatar
+ 1
starting with 0 change number to octal .
15th Mar 2017, 3:48 PM
Sahaj Bamba
Sahaj Bamba - avatar
+ 1
thanks @Sahaj and also when I replaced int a=028; it showed integer number too large..... anyone pls explain?
15th Mar 2017, 3:58 PM
Manideep Yadav
Manideep Yadav - avatar