Java data type (basic data type) learning
As with other languages, Java programming also exists, such as int a,float B. I have to understand the Java data type before I can learn the variables.
The data types of Java include basic data types and reference data types. Specific as follows:
The value ranges for each data type are as follows:
type name |
keyword |
occupied bytes |
value range |
byte-type |
byte |
1 |
-2^7~2^7-1 |
Span style= "font-size:10pt" > short integer |
short |
2 |
-2^15~2^15-1 |
integer |
int |
4 |
-2^31~-2^31-1 |
Span style= "font-size:10pt" > long int |
long |
8 |
-2^63~-2^63-1 |
single precision floating-point type |
float |
4 |
-3.4e38~3.4e38 |
Span style= "font-size:10pt" > double precision floating-point type |
double |
8 |
-1.7e308~1.7e308 |
character type |
char |
2 |
0~65535 |
Boolean type |
Boolean |
1 |
True or False |
The range of values for each type can also be tested like this:
- Public class javatest2{
- Public Static void Main (string[] args) {
- System.out.println (byte.max_value+ "" +byte.min_value);
- System.out.println (short.max_value+ "" +short.min_value);
- System.out.println (integer.max_value+ "" +integer.min_value);
- System.out.println (long.max_value+ "" +long.min_value);
- System.out.println (float.max_value+ "" +float.min_value);
- System.out.println (double.max_value+ "" +double.min_value);
- }
- }
Java data type (basic data type) learning