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

Top comments (0)