Data Type

A Data type is a scheme for representing values. An example is int which is the Integer, a data type. Values are not just numbers, but any manner of data that a computer can process. The data type defines the kind of data that is represented by a variable. As with the keyword class, Java data types are case sensitive. There are two types of data types. 

  • Primitive data type
  • Non-primitive data type 


Primitive data type

In primitive data types, there are two categories numeric means Integer, Floating points Non-numeric means Character and Boolean.


Integer datatype can hold the numbers (the number can be positive number or negative number). In Java, there are four types of integer as follows:

  • Byte
  • Short
  • Int
  • Long

We can make integer long by adding ‘l’ or ‘L’ at the end of the number.

Floating Data Type

It is also called as Real number and when we require accuracy then we can use it. There are two types of floating point data type.

  • Float
  • Doble

It is represent single and double precision numbers. The float type is used for single precision and it uses 4 bytes for storage space. It is very useful when we require accuracy with small degree of precision. But in double type, it is used for double precision and uses 8 bytes of starage space. It is useful for large degree of precision.

Character data type

It is used to store single character in memory. It uses 2 bytes storage space.

Boolean data type

It is used when we want to test a particular condition during the excution of the program. There are only two values that a boolean type can hold: true and false. Boolean type is denoted by the keyword boolean and uses only one bit of storage.

Non-primitive data type

In non-pimitive types, there are three categories 

  • Classes
  • Array
  • Interface