Data Types in JAVA
In this article, we are going to discuss about data types in java.
Data Types;
- This is the type of data which can be used in the program.
- There are various predefined data types in the java library like int, char, float etc.
Type of Data Type
Primitive Data Type
- The data type which is predefined in the library is called primitive data type.
- This is named by the keyword, for example int, float, char etc.
- There are eight primitive data types in java.
Integer Type;
Type | Size in bytes | Range |
byte | 1 | -128 to 127 |
short | 2 | -32,768 to 32,767 |
int | 4 | -2,147,483 to 2,147,483,647 |
long | 8 | -9,223,372,036,854,775,808 to 9,223.372,036,854,775,808
|
Float Type;
Keyword | char | Range |
syntax | Char x | 3.4e-038 to 3.4e+038 |
value | ‘a’, ‘@’, ’9’ | 1.7e-308 to 1.7e+038 |
Boolean;
Keyword | boolean |
syntax | boolean x |
value | True/False |
Range | False |
Character;
Keyword | char |
syntax | Char x |
value | ‘a’, ‘@’, ’9’ |
Range | 0 to 65536 |
Non-primitive Data Type;
- The data type which is derived from primitive data type is called non-primitive data type.
- It is also called reference data type.
- These will not store the value, but store a reference to that value.
- Example: Array, class, interface etc.
This is regarding data types in java. Thanks for reading.
For Videos Join Our Youtube Channel: Join Now