This table shows the size and range of the primitive data types available in java.

Type Bits

Range

Object Default Notes
min max
boolean true false Boolean false
byte 8 -27 27-1 Byte 0
short 16 -215 215-1 Short 0
char 16 0 216 Character \u0000 \uxxxx, xxxx 4 hex digit
int 32 -231 231-1 Integer 0 Default integer type
long 64 -263 263-1 Long 0
float 32 -231 231-1 Float 0.0 postfix letter l/L
double 64 -263 263-1 Double 0.0 Default floating point type
reference Null

The following table display examples of good and bad number formation.

Type Examples
Good Bad
boolean
byte
short
char ‘\t”\342’

‘a’

int i = 5;

char c = (char)i;

‘\u05D0’0x980

4+6

‘436’“a”

3.4

0453“a string”

int i = 5;

char c = i;

int
long
float
double 1.2345E02 1.2345e-6 1.2345 1e-6 1.2345 * 10^2
reference

Octal and hexadecimal numbers:

  • Octal number start with: 0 (zero);
  • Hexadecimal numbers start with 0x or 0X (zero x);

Leave a comment