DEV Community

Anjali Gurjar
Anjali Gurjar

Posted on

Primitive and Non primitive data types

primitive data types store single values, while non-primitive data types store multiple values. Primitive data types are faster and use less memory than non-primitive data types.
Primitive data types
Examples: Integers, floats, booleans, and characters
Characteristics: Always have a value, fixed size, and are stored in the stack
Use cases: Storing simple values, basic arithmetic, and boolean logic
Non-primitive data types
Examples: Arrays, linked lists, stacks, classes, interfaces, and strings
Characteristics: Can have null values, variable size, and are stored in the heap
Use cases: Calling methods to perform operations
Differences between primitive and non-primitive data types
Size
Primitive data types have a fixed size, while non-primitive data types can vary in size
Memory efficiency
Primitive data types are more memory efficient than non-primitive data types
Speed
Primitive data types are faster than non-primitive data types
Value
Primitive data types always have a value, while non-primitive data types can have null values
Letter case
Primitive data types start with a lowercase letter, while non-primitive data types start with an uppercase lette

AWS GenAI LIVE image

Real challenges. Real solutions. Real talk.

From technical discussions to philosophical debates, AWS and AWS Partners examine the impact and evolution of gen AI.

Learn more

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs