+ 2

Why this code is giving ERROR

int a=028; System.out.println (a); OUTPUT: error

25th Feb 2017, 9:22 PM
Pradeep gupta
Pradeep gupta - avatar
6 Answers
+ 4
Pradeep, Because any number starting with "0" is considered to be an octal value, and there is no digit above 7 in octal notation. In octal, 030 is next after 027. If you try and observe you may understand, try 027 its working but not 028 because of above reason.
25th Feb 2017, 9:43 PM
Salman Mushtaq
Salman Mushtaq - avatar
+ 1
Pradeep, this is because you try to save large integer like 028, try with 28 its working.
25th Feb 2017, 9:28 PM
Salman Mushtaq
Salman Mushtaq - avatar
+ 1
thnks guys
25th Feb 2017, 10:06 PM
Pradeep gupta
Pradeep gupta - avatar
0
turn 028 into 28, this should fix.
25th Feb 2017, 9:31 PM
André Morales
André Morales - avatar
0
why 028 is large value for int type
25th Feb 2017, 9:32 PM
Pradeep gupta
Pradeep gupta - avatar
0
why it is error? I can't understand! can anyone explain still clearly?
30th Apr 2017, 7:13 AM
S.ISHWARYA