A data type just is an attribute of data that tells the compiler how the programmer intends to use the data; in other words, which format the data will be stored.

types of data types in Java:
  • Primitive data types: The primitive data types consist of boolean, char, byte, short, int, long, float, and double.
  • Non-primitive data types: The non-primitive data types consist of String, Classes, Interfaces, and Arrays.
Here’s a list of all primitive data types :
Long864-263 to 263-1long n = 6500000L;
Int432-231 to 231-1int n = 5000000;
Short216-215 to 215-1short n = 10000;
Byte18-2to 27-1byte n = 90;
Double864Precision = 15 digitsdouble n = 15.7d;
Float432Precision = 6-7 digitsfloat n = 4.68f;
Char2160 to 216-1char c = ‘A’;
char c = 67;
Boolean1 –True/falseboolean isFunny = true;
Note : Following is the ASCII code for commonly used characters –
0-9 char = ASCII (0-9)
A-Z char = ASCII (65-90)
a-z char = ASCII (97-122)
Here’s a list of non-primitive data types:
A String is used to store sequence of characters that can also contain spaces and numbers surrounded by double quotes.
A Class is like a template that is used to create and define objects, object data types, and methods.An interface is a reference type that a class implements, thereby inheriting the abstract methods of the interface.An Array is treated as an object of fixed size which contains elements of a similar data type.
An object that contains multiple methods is basically a String. For instance, method to find its length, converting to upper or lower case, trimming text or replacing text.The declaration of a class consist of access modifiers, class name, keyword and the body. It allows you to declare a variable along with its data type.It consist of methods and variables, but the methods declared are abstract(In other words, method with no body, only signature) by default in an interface. We can declare, instantiate, initialize and traverse an array. Array declaration has two components: the type like primitive or user defined and the name.
String s = “How are you?”;public void class Test {
// class body
interface Test {
public void print();
int boxes[];
int[] boxes;