Home > Java > javaTutorial > Comprehensive analysis of basic data types in JAVA foundation

Comprehensive analysis of basic data types in JAVA foundation

高洛峰
Release: 2017-01-24 13:48:16
Original
1275 people have browsed it

Basic data types:

1. Numeric type

1) Integer:

1. byte is a byte, 8 bits, with a value range of 0 ~255, used to store binary data.
2. Short is two bytes, 16 bits, and the value range is between -32768~32767.
3. Int four bytes, 32 bits, the value range is between -2147483648~2147483648
4. long eight bytes, 64 bits, the value range is between -9,223,372,036,854,775,808 ~9,223,372,036,854,775,807

2) Floating point type:

1, float, four bytes, single precision floating point number, range is -2^128
~ +2^128
2. Double, eight bytes double-precision floating point number, range is -2^1024
~ +2^1024

2. Character type: char, a set of data

3. Boolean type: boolean, only two values, one true and one false

4. String: String,

Basic data type conversion:

Low-level to Advanced can automatically convert
char→int→long→float→double
byte→short→int

force conversion
double num1=78.2;
int num2=(double)num1

The above comprehensive analysis of the basic data types of JAVA is all the content shared by the editor. I hope it can give you a reference, and I also hope that everyone will support the PHP Chinese website.

For more articles related to the comprehensive analysis of basic data types in JAVA, please pay attention to the PHP Chinese website!


Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template