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

How to use operators in JAVA

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2023-05-26 10:31:42
forward
1533 people have browsed it

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!

Related labels:
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
Latest Issues
Install JAVA
From 1970-01-01 08:00:00
0
0
0
Unable to install java
From 1970-01-01 08:00:00
0
0
0
Can java be used as the backend of the web?
From 1970-01-01 08:00:00
0
0
0
Is this in Java language?
From 1970-01-01 08:00:00
0
0
0
Help: JAVA encrypted data PHP decryption
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template