Java data types

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:

  1. Primitive data types
  2. 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:

  1. byte – 8bit, and number.
  2. short – is number type and takes two bytes.
  3. int – is a numeric data type and takes four bytes.
  4. long – is numeric and takes eight bytes.
  5. float – is a single precision and takes four bytes.
  6. double – is a double precision and takes eight bytes.
  7. char – can store any character and takes two bytes.
  8. 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.

Also see Java integer | Java byte | Java long

Was this article helpful?

Related Articles

Leave A Comment?