DEV Community

Cover image for JSP 1 : Variables, Data Types, Operators
Sophie Muchiri
Sophie Muchiri

Posted on

JSP 1 : Variables, Data Types, Operators

DATA TYPES & OPERATORS

DATA TYPES

A data type is a classification that specifies the type of data a variable can hold in a programming language

**

Common Data types are:
**

  • Numbers
  • Strings
  • Booleans

Primitive Data types

  • Primitive data types are data types that represents single values

  • They are immutable hence values cannot be changed,however, you can reassign a new value to the variable holding the primitive data type

-They are stored by value meaning they are stored directly into a variable memory location

  • Have a fixed size hence occupy a fixed amount size of memory therefore storage is in stacks

They include :

  1. Numbers
  2. strings
  3. boolean

Examples

Image description

Non-Primitive Data types

Non-primitive data types are more complex and can hold multiple values

  • They store multiple values.
  • They are modifiable and dynamic.
  • They use more memory and are slower than primitive types.
  • They often require additional operations (e.g., accessing elements) They include:

Objects : Collection of keys and value pairs where keys are strings and values can be of any data type

Image description

Arrays : Ordered collections of elements that can be of any data type

Image description

Functions

Image description

Maps

Image description

Sets

Image description

Hostinger image

Get n8n VPS hosting 3x cheaper than a cloud solution

Get fast, easy, secure n8n VPS hosting from $4.99/mo at Hostinger. Automate any workflow using a pre-installed n8n application and no-code customization.

Start now

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

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay