Java Data Types

Data types are used to declare a variable before its use. Data types represents the type of information present in a variable. Data types are the keywords, which are used for assigning a type to a variable.

Different Data Types available in Java

Primitives Data Type

  • Integer Type
  • Float-point Type
  • Character Type
  • Boolean Type

Non-Primitive Data Types

  • Class
  • Array
  • Interface

Primitives Data Type

Integer Type

Integer data type are like whole numbers, they also include negative numbers but does not support decimal numbers.

TypeStorage sizeValue rangeDefault Value
byte1 bytes-128 to 1270
short2 bytes-32,768 to 32,7670
int4 bytes-2,147,483,648 to 2,147,483,6470
long8 bytes-9,223,372,036,854,775,808 to

Float-point Type

Float data type allows user to store decimal values in a variable.

TypeStorage sizeValue rangeDefault Value
float4 byte1.4e-045 to 3.4e+0380.0f
double8 byte4.9e-324 to 1.8e+3080.0

Character Type

Character data type is used to store only one letter, digit, symbol at a time. Java character uses unicode rather than ASCII code. '\u0000' is the smallest unicode and '\uffff' is the kargest unicode.

TypeStorage sizeValue rangeDefault Value
char1 byte0 to 65,536'\u0000'

Boolean Type

The boolean data type has only two possible values either true or false. Boolean data type represents one bit of information.

TypeStorage sizeValue rangeDefault Value
boolean1 bitHas no range.false

Non-Primitive Data Types


Class is an encapsulation of data and coding. Class is userdefined datatype. Variables declared in class are called Data Members. Functions defined in class are called Member Functions. More info


Array is a collection of similar data type. More info


Interface is used in situation, when we need to restrict derived class to implements all methods. This can be done by making abstract class with all abstract methods, then why use interface? The answer is... More info