0

why output so strange 0022 =18? hello everyone to day i have test.the question is "what is the output of

System.out.println(0022);

i so confuse why Answer is 18

explain needed

1 Answers1

5

If the first digit of an int literal is 0, Java interprets the number in octal (base 8).

Epiglottal Axolotl
  • 1,048
  • 8
  • 17