1

This Q is for verification.

JDK 8 seems to be processing octal when the literal value is preceeded with a 0:

  System.out.print(011);

printing 9, and

  System.out.print(08);

giving a checked error.

This isn't in the docs-- yet(?)

Is this new in jdk8? if so - are there some details in case of octal, additional to those in HEX and binary?

TIA

//=============================

EDIT:

The Q is about JDK processing octal-- since when. the dosc showing only HEX & binary.

that 2nd code line is there to show it's octal JDK doing when the value is preceeded by a 0.

user3880721
  • 613
  • 6
  • 16

1 Answers1

9

It's been in Java forever... the bit of the JLS you want is section 3.10.1:

An octal numeral consists of an ASCII digit 0 followed by one or more of the ASCII digits 0 through 7 interspersed with underscores, and can represent a positive, zero, or negative integer.

(It's in the first edition of the JLS too.)

You shouldn't expect the Java tutorial to be complete on every aspect of the language - that would be overwhelming for the target audience. For aspects like this, the specification is the document to be looking at.

Jon Skeet
  • 1,421,763
  • 867
  • 9,128
  • 9,194