What is data Type ?
Java is a statically type language , means every variable must be declared with a specific data type before it can be used.
int age = 10 ; String name = "ajay"
Enter fullscreen mode
Exit fullscreen mode
Data types are divided into,
1) Primitive data type,
2) Non-primitive data type.
1) Primitive data type:
Primitive data type specifies the type of the variable and store the value
Number:
byte(8 bit) --> Stores the whole number from -128 to 127 (2**8 = 256)
short(16 bit) ---> Stores whole numbers from -32,768 to 32,767 (2**16 = 65,536)
int(32-bit) ---> stores whole number from -2,147,483,648 to 2,147,483,647 (2**32 = 4,294,967,296)
long(64 bit) --->Stores whole numbers from -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807 (2**64 = 18,446,744,073,709,551,616)
Decimal number :
float(32 bit) --->Single-precision decimal. Requires an f suffix.Sufficient for storing 6 to 7 decimal digits
double(64 bit) --->Double-precision decimal (default for decimals).…