Java is statically typed language.
Before using a variable, it should be declared with a data type.

Data types in java can be categorized into 2 broad types, primitive data types and reference data types.
Primitive data types come along with JDK which are built-in with platform.
Primitive data types are also called as value types.
Reference data types are also called as user-defined data types.

Data types in java
primitive data types reference types
byteClass
shortObject
intInterface
longArray
floatString
doublenull
char
boolean

Primitive Data Types:

The built-in data types in java are known as the primitive data types. There are 8 primitive types supported by Java.

Primitive data types are categorized into four groups:

Integer type:

It can store whole number values . The of the values of the variables depends upon the chosen Integer data type. The four Integer data types are: 1.byte 2.short 3.int 4.long
byte - 8 bit size signed min value -128 and maximum value +127 default value is 0 Mostly used for large arrays of numerical values to save memory. short - 16 bit size signed min value -32,768 and maximum value +32,767 default value is 0 int - 32 bit size signed min value -2(31) and maximum value +2(31)-1 default value is 0 Most of the numerical operations can be used with this type long - 64 bit size signed min value -2(63) and maximum value +2(63)-1 default value is 0L Used only to store large numerical values like milliseconds of a timer.

Floating point type:

It can store fractional numbers. The two types of floating types are: 1.float 2.double float - 32 bit, single precision IEEE 754 floating point. signed default value is 0.0f Used for normal real operations, but not suggestible for more precision values. double - 64 bit, single precision IEEE 754 floating point. signed default value is 0.0d Use it when you need better precision values, esp for scientific calculations.

Boolean type:

It can store only the true and false values. Boolean data type is required when a condition has to be checked. The true or false value of the expression or the condition determines further execution of the java program.

Example for using primitive data types:

public class TypesDemo {
	public static void main(String[] args) {
		byte b = 32;
		short s = 123;
		int i = 234;
		long l = 2345L;
		
		char ch = 'a';
		
		float f = 32.2f;
		double d = 1234.5;		
		boolean bool = true;
	}
}

Reference Data Types:

Reference data types are also called as user-defined data types. Most of these data types are defined by the programmer. There are 6 reference types in java:

Class, Object, Array, Interface, String, and null.

Reference types are stored in heap, as they are of bigger size. Reference types default value is null. Reference data type, generally refers to an object in the memory. Though it is too early to discuss about these types, here is a simple example.

Example for using Reference data types:

/*
 * A simple example program for Reference types in java  
 */
public class RefTypesDemo {
	public static void main(String[] args) {
		String str = "hello"; //example for Strings
		int[] arr = {1,2,3,4,5}; // example for array
		Test t = new Test();//example for object
		Test u = null;//example for null
	}
}
//example for class
class Test{
	int i=10;
	public void display(){
		System.out.println(i);
	}
}
//example for interface
interface MyInterface{
	public void display();
}
We will try to understand more about reference data types in coming sections.

Difference between value types and reference types