+ 2
What is the answer of this code and why?
int x = 01012; System.out.println("value of x is"+ x);
3 ответов
+ 3
Integers that begin with 0 will result in an octal.
01012 is the octal (base 8) value for the decimal (base 10) 522
+ 3
1 0 1 2
(1*8^3)+(0*8^2)+(1*8^1)+(2*8^0)
(1*512)+(0*64) + (1*8) +(2*1)
512+0+8+2
522
Any value prefixed with 0 means it is in octal. So that value will deduce to 522.
+ 1
Okk thanku so muchh...