Java basic syntax (2) – basic data types

preface

You can directly copy other people's notes, only do typesetting and combing, and you may add your own opinions

Java data types

What are several basic data types in Java?

There are eight basic data types in Java

Bit

It is the smallest unit of data storage in the computer. 11001100 is an eight bit binary number

Byte

character

It refers to the letters, numbers, words and symbols used in the computer

How many bytes do they occupy?

The default values of these 8 basic data types and the space occupied are as follows:

In addition, the official document does not clearly define the Boolean, which depends on the specific implementation of the JVM vendor. Logically, it takes up 1 bit, but in practice, the factor of efficient computer storage will be considered

Foundation type precautions

Value range of byte, short, int and long in integer

Type conversion

Because Java is a strongly typed language, type conversion is required when some operations are required.

Low ----------------------------------------- > High

byte, short, char -> int -> long -> float -> double

(decimals take precedence over integers)

Automatic type conversion

Direct input from low to high without coercion

Conversion attention

What are the corresponding packaging classes?

Basic type and package type considerations

Single precision, double precision

Floating point extension

For accurate reconciliation, it is best to completely avoid using floating-point numbers for comparison

For accurate reconciliation, it is best to completely avoid using floating-point numbers for comparison

For accurate reconciliation, it is best to completely avoid using floating-point numbers for comparison

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>