5

Is

00, 000, or 000...

an integer in Java? Or is it an octal? If is it an octal is

001 or 0005

an octal?

Roman C
  • 49,761
  • 33
  • 66
  • 176
stcho
  • 1,909
  • 3
  • 28
  • 45

3 Answers3

7

All are integers, but...

1  is decimal
0  is decimal
01 is octal
00 is octal

From Java Language Specification (emphasis mine):

Note that octal numerals always consist of two or more digits; 0 is always considered to be a decimal numeral - not that it matters much in practice, for the numerals 0, 00, and 0x0 all represent exactly the same integer value.

Christian Tapia
  • 33,620
  • 7
  • 56
  • 73
4

Number literal representation examples in Java will give you the answer:

int decimal = 100;
int octal = 0144;
int hex = 0x64;
int binary = 0b1100100;

So 00, 000 and 0000 are all octal(base-8) integers.

Juvanis
  • 25,802
  • 5
  • 69
  • 87
1

Directly from specification

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

You can check 0 though 7

Suresh Atta
  • 120,458
  • 37
  • 198
  • 307