The data types in Java
The variables are the way to store data in the programming languages. In Java, you have to specify a data type of variables that tells what kind of data to be stored in it. Depending on the data types the operating system allocates memory and decides what type of data to be stored e.g. a number, a character etc.
There are two kinds of Java data types:
- Primitive data types
- Object data types also known as the Reference data types
This chapter focuses on the primitive data types in Java. Primitive data types are those that are defined by language and a keyword. Just like other programming languages Java supports primitive data types.
There are eight primitive data types in Java. These data types are listed below along with the links to their chapters.
Primitive data types in Java
The eight primitive data types in Java are:
- byte – 8bit, and number.
- short – is number type and takes two bytes.
- int – is a numeric data type and takes four bytes.
- long – is numeric and takes eight bytes.
- float – is a single precision and takes four bytes.
- double – is a double precision and takes eight bytes.
- char – can store any character and takes two bytes.
- boolean – It takes one byte and can store either of two values: True or False.
Click on any data types to go to its detailed chapter with the examples.