Types of Variables

In this lesson, we will look at two broad categories of variables in Java.

In the last lesson, we saw how variables in Java have different types, e.g., int, boolean, etc. We can broadly classify these variable types, also called data types, into two categories:

  • Primitive data types
  • Reference data types

Primitive data types

The variables with primitive data types directly store the data, i.e., the primitive value is stored in memory reserved by a primitive variable. The primitive data type is the most basic data type in Java. There are eight data types that fall into this category: boolean, short, int, long, char, float, double, and byte.

Get hands-on with 1400+ tech skills courses.