Home >Java >javaTutorial >How to use operators in JAVA

How to use operators in JAVA

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBforward
2023-05-26 10:31:421531browse

1. Arithmetic operators

Operator: Common ±*/etc.

Expression: The operators are connected in accordance with java Syntax formula, such as a b

arithmetic operator: - * / %

Note: To get decimals, there must be floating point numbers in it Participate

How to use operators in JAVA

When printing, char and int are converted according to ASCII code

How to use operators in JAVA

The " " of string is the string concatenation operator, that is, splicing

2. Assignment operator

Assignment operator: a=10 , don’t say that a is equal to 10, but say that 10 is assigned to the variable a

Note: When performing =, -=, *=, /=, %= operations, type conversion will be automatically forced

3. Auto-increment and auto-decrement operators

is, –
Note: The result of a single i is the same as i, but there is a difference when assigning values: j=i becomes j=i,i;j = i becomes i, j=i

4. Relational operators

Relational operators: ==,! =, >, >=,

5. Logical operators

Logical operators:&, |, ^,! , the output is a Boolean value

Short-circuit logical operators: &&, ||, the result is the same as above. However, if the front of && is false, the following will not be executed; if the front of || is true, the following will not be executed (short-circuit effect)

6. Ternary operator

Format : Relational expression? Relationship 1: Relationship 2

7. Data input

Scanner usage steps: 1. Guide the package; 2. Create the object; 3. Receive data.

How to use operators in JAVA

The above is the detailed content of How to use operators in JAVA. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:yisu.com. If there is any infringement, please contact admin@php.cn delete