Skip to content

Latest commit

 

History

History
27 lines (19 loc) · 972 Bytes

02-2-datatypes.md

File metadata and controls

27 lines (19 loc) · 972 Bytes

2.2 Data Types

Primarily we divide data types into 2 categories :

  • Primitive
  • Non Primitive

Primitive Data types

Datatype Range Size
boolean true/false Not defined
char 0 to 65,536 2 bytes
byte -128 to 127 1 byte
short -32,768 to 32,767 2 bytes
int -2,147,483,648 to 2,147,483, 647 4 bytes
long -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807 8 bytes
float approx. ±3.40282347E+38F (6-7 significant decimal digits) 4 bytes
double approx. ±1.79769313486231570E+308 (15 significant decimal digits) 8 bytes

Primitive datatypes are stored in the stack.

Non Primitive Data types

Everything other than above mentioned types are non primitive data types. Some of them are String, Array, etc.

The reference of a non primitive data type is stored in the stack and memory is allocated in heap. We'll discuss more about non-primitives later.