Written by - Yash Agrawal

Data Types in Java


Data types define different size and values that can be stored in the memory and according to that we can apply certain operations.

Types:

  1. Primitive data types: This includes char, float, int, boolean, byte short, long, double.
  2. Non-primitive data types: This includes Classes, Interfaces, Arrays.

Primitive Data Type:

This is the most basics ones. There are 8 types of primitive data types:
  • boolean data type
  • char data type
  • byte data type
  • float data type
  • long data type
  • int data type
  • double data type
  • short data type
Data TypeDefault ValueDefault size
booleanfalse1 bit
char'\u0000'2 byte
byte01 byte
short02 byte
int04 byte
long0L8 byte
float0.0f4 byte
double0.0d8 byte

Non - Primitive Data Type

This contains strings(array of characters), classes and interfaces, these are more complex then primitive data types.