java - Leading zeroes in Integer array leading to different values being printed -
this question has answer here:
- regarding leading 0 in integer value 3 answers
why value printed not same input? leading zeroes change way integer read?
integer[] secondarray = {02,03,04,05,06,011,012,012,0123}; system.out.println("values:" + arrays.tostring(secondarray));
output: 2, 3, 4, 5, 6, 9, 10, 10, 83
a leading 0 in integer literal in java (and lot of other languages) means octal number (base 8).
so 011
nine.
other systems can use hex (0x09
, base 16) , binary (0b1001
, since java7).
Comments
Post a Comment