It specifies the type and size of a variable. They are grouped into 2 types :
1. Primitive data types: They are of type boolean, char, byte, short, int, float, long and double.
2. Non-primitive data types: They are interfaces, classes, and arrays.
Types of primitive data types:
Data Type | Default Size | Default Value |
boolean | 1 bit | FALSE |
byte | 8 bit | 0 |
char | 2 byte | '\u0000' |
short | 2 byte | 0 |
int | 4 byte | 0 |
float | 4 byte | 0.0f |
long | 8 byte | 0l |
double | 8 byte | 0.0d |
Note: char uses 2 bytes of java and it has \u0000 as its default value because it java uses Unicode system not the ASCII code system. Unicode system has \u0000 as the lowest range so it is assigned as the default value.
☛ Next >> String in Java
A string is immutable in Java. String class represents character str ...
☛ Next >> String in Java
A string is immutable in Java. String class represents character str ...
No comments:
Post a Comment