Data-Types were available in Java.
Hello guys, Today we are looking for Data-Types in Java. There are various data types are available in Core Java. So let's jump to the blog post.
A variable is an identifier that denotes a storage location used to store a data value.
As you see in the above diagram or figure the data types are divided in this manner. Data Type is a type assign to variable names that specify the type of data we store in the variable. Actually, there are mainly two types in java 1) Primitive and 2) Non-Primitive.
The primitive data types also divided into some types of Numeric and Non-Numeric Data Types.
1) byte- One byte- -128 to 127.
2) short- Two bytes- -32,768 to 32,767.
3) int- Four bytes- -2,147,483,648 to 2,147,483,647.
4) long- Eight bytes- -9,223,372,036,845,775,808 to 9,223,372,036,845,775,807.
b) Floating Point-
5) float- 4-bytes- 3.4e-038 to 1.7e+0.38.
6) double- 8-bytes- 3.4e-038 to 1.7e+308.
8) boolean- 1-bit- True and False.
eg. Array, enum, String, etc.
float x = true;
double no3;
data_type variable_name = value;
![]() |
Data Types in Java |
A variable is an identifier that denotes a storage location used to store a data value.
As you see in the above diagram or figure the data types are divided in this manner. Data Type is a type assign to variable names that specify the type of data we store in the variable. Actually, there are mainly two types in java 1) Primitive and 2) Non-Primitive.
1) Primitive Data Types:-
Primitive Data Types are those data types which represent single data member. In java, there is a total of 8 (Eight) Primitive Data Types. Primitive Data Types also called Intrinsic Data Types.The primitive data types also divided into some types of Numeric and Non-Numeric Data Types.
Numerical:-
a) Integer-1) byte- One byte- -128 to 127.
2) short- Two bytes- -32,768 to 32,767.
3) int- Four bytes- -2,147,483,648 to 2,147,483,647.
4) long- Eight bytes- -9,223,372,036,845,775,808 to 9,223,372,036,845,775,807.
b) Floating Point-
5) float- 4-bytes- 3.4e-038 to 1.7e+0.38.
6) double- 8-bytes- 3.4e-038 to 1.7e+308.
Non-Numerical:-
7) char- 2-bytes8) boolean- 1-bit- True and False.
2) Non-Primitive Data Types:-
Reference/Non-Primitive Data Types are those data types that represented a group of data members. In JAVA we have data these types like classes. All the classes are Non-Primitive data types.eg. Array, enum, String, etc.
Some examples of variables:-
int no1 = 23;float x = true;
double no3;
Syntax for declraring a variables
data_type variable1, var2, var3..... varN;data_type variable_name = value;
0 Comments