Java basic syntax — understanding of variable operator

variable

Variable overview

Variables must have clear types, what types of variables are installed in what types of data.

Basic types in 8: byte, short, int, long, float, double, char, Boolean

Define variable syntax format:

Data type variable name = data value;

Precautions for the use of variables: I: variables can be assigned without assignment after they are fixed, and they can be assigned again when they are used. Cannot be used without assignment.

2: There are scope restrictions when using variables.

Data type conversion

operator

① Arithmetic operator:

+It is converted to a string only when it is added directly to the string.

② Assignment operator:

③ Comparison operator:

Note the difference between the = sign in the assignment operator and the = = sign in the comparison operator.

④ Logical operators:

Short circuit & &: the data on both sides involved in the operation is false, then the operation result is false;

Short circuit or |: if the data on both sides involved in the operation is true, the operation result is true.

⑤ Ternary operator:

(conditional expression)? Expression 1: expression 2;

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
分享
二维码
< <上一篇
下一篇>>