java - Leading zeroes in Integer array leading to different values being printed -


this question has answer here:

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

Popular posts from this blog

Ansible - ERROR! the field 'hosts' is required but was not set -

customize file_field button ruby on rails -

SoapUI on windows 10 - high DPI/4K scaling issue -