Data TypeSizePrimitive/ReferenceValue
boolean1 bitprimitivetrue or false
byte1 byteprimitive-128 to 127
short2 bytesprimitive-32,768 to 32,767
int4 bytesprimitive-2 billion to 2 billion
long8 bytesprimitive-9 quintillion to 9 quintillion
float4 bytesprimitivefractional number up to 6-7 digits (e.g., 3.141592f)
double8 bytesprimitivefractional number up to 15 digits (e.g., 3.141592653589793)
char2 bytesprimitivesingle character/letter/ASCII value (e.g., ‘f’)
Stringvariesreferencea sequence of characters (e.g., “Hello world!“)

Note

If u need to assign value to float data type u need to add f at end of the number, but not in double


Primitive vs Reference Data Types

Drawing 2024-08-28 03.41.15.excalidraw

⚠ Switch to EXCALIDRAW VIEW in the MORE OPTIONS menu of this document. ⚠ You can decompress Drawing data with the command palette: ‘Decompress current Excalidraw file’. For more info check in plugin settings under ‘Saving’

Excalidraw Data

Text Elements

Primitive

reference

  • 8 types

  • stores data

  • less memory

  • faster

  • can only hold 1 value

  • unlimited (user defined)

  • stores and address

  • more memory

  • slower

  • could hold more than 1 value

Link to original