Data Types In Java


Data Types in Java

  • Primitive data type
  • Non Primitive data type or Reference data type

There are 8 types of primitive data types:

short data type

int data type

long data type

float data type

double data type

boolean data type

byte data type

char data type

Non Primitive data type or Reference data type

Arrays and Strings are non-primitive data types


In the following table we can find the default values of different data types.

Type

Value

Default value

Size

short

twos complement integer

0

16 bits

int

twos complement integrin

-2, -1, 0, 1, 2

0

32 bits

long

-2L, -1L, 0L, 1L, 2L

0

64 bits

float

IEEE 754 floating point

1.23e100f, -1.23e-100f, .3f, 3.14F

0.0

32 bits

double

IEEE 754 floating point

1.23456e300d, -1.23456e-300d, 1e1d

0.0

64 bits

boolean

true or false

false

1 bit

byte

twos complement integer

0

8 bits

char

Unicode character

\u0000

16 bits





Related Tutorials