DataTypes - Ehsangood1/Programmign-2 GitHub Wiki

In Java, data types specify the different sizes and values that can be stored in variables. Java is a statically typed language, meaning every variable must have a declared type.

Categories of Data Types

Primitive Data Types

Reference Data Types

1. Primitive Data Types

Primitive types are the most basic data types built into the Java language. They are not objects, and they store their values directly in memory. Like byte, short, int, long, float, double, boolean, char

Example

2. Reference Data Types

Reference types store references (or addresses) to the actual data rather than the data itself. All reference types are derived from the base class Object.

Common Reference Data Types:

  • Classes: User-defined or predefined types such as String, Scanner, ArrayList, etc.
  • Interfaces: Like Runnable, Serializable, etc.
  • Arrays: Collections of variables of the same type

Example