Java/English
Java variable_2_Primitive Data type
JunJe
2020. 12. 30. 16:34
Data type
In Java, there are different method of declaring variables for example,
- Integer Type
- Real Numbers
- Character
- Logic
For each type, there are different mothods.
For Interger type,
byte | bit | range | |
byte | 1 | 8 | -128~127 |
short | 2 | 16 | -32,768~32,767 |
int | 4 | 32 | -2,147,483,648~2,147,483,647 |
long | 8 | 64 | -2^63~2^63-1 |
For Real Numbers,
byte | bit | range | |
float | 4 | 32 | 1.4x10^45~3.4x10^38 |
double | 8 | 64 | 4.9x10^-324~1.8x10^308 |
There are range of errors too.
Float is most accurate under 6 decimal points while double is most accurate under 15 decimal points.
(Normaly, float is used to decrease the amount of memory used while running (such as making games). However, the computers' memory have increased dramatically during recent years, using double is recommended because its accuracy.)
For Character,
byte | bit | range | |
char | 2 | 16 | 0~2^16-1 (uni-code 0~65535) |
For logic,
byte | bit | range | |
boolean | 1 | 8 | true, false |