Is 00 integer or octal in Java?

Is an

00, 000 or 000 ...

integer in java? Or is it an octal? If it is an octal value

001 or 0005

octal?

+4
source share
3 answers

All are integers , but ...

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

From the Java Language Specification (highlighted by me):

Note that octal digits always consist of two or more digits; 0 is always considered a decimal digit , but this is not very important in practice, since the numbers 0, 00 and 0x0 represent exactly the same integer value.

+6
source

Java :

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

, 00 000 0000 - ( 8) .

+4

Directly from the specification

The octal digit consists of the ASCII digit 0, followed by one or more ASCII digits from 0 to 7, and may represent a positive, zero, or negative integer.

You can check 0 though 7

+1
source

Source: https://habr.com/ru/post/1543171/


All Articles