in this chapter we will learn data types in java like character, string, integer, double, Boolean and there are many data types that we will explore one by one.

Data types are divided into two types:

  1. Primitive data types - byte, short, int, long, float, double, boolean and char
  2. Non-primitive data types - such as String, Arrays and Classes 

Primitive Data Types:

It is used to manipulate of size and type of variable values.

There are eight primitive data types in Java:

  1. boolean data type
  2. byte data type
  3. char data type
  4. short data type
  5. int data type
  6. long data type
  7. float data type
  8. double data type

Data Type Default Value Default size
boolean false 1 bit
char '\u0000' 2 byte
byte 0 1 byte
short 0 2 byte
int 0 4 byte
long 0L 8 byte
float 0.0f 4 byte
double 0.0d 8 byte

Integer Types

Here are a few examples to store different types of integer values


byte myByte = 100;


short myShort = 500;


int myInt = 50000;


long myLong = 1500000L;


Inside a Boolean data type you can store true and false value in a variable

boolean isLike = true;


Inside a Character data type you can store a single character in a variable

char myGrade = 'B';


it is used to store fractional numbers

double myDouble = 19.99d;

There are many data types we will discuss more on our further chapters like this article please give a thumbs up