Detailed introduction to Java basic operators and logic control (with examples)
This article brings you a detailed introduction to the basic operators and logic control of Java (with examples). It has certain reference value. Friends in need can refer to it. Hope it helps.
Operators and logic control
Operators
Operators in java can be divided into the following types:
Operators
Relational operators
Bitwise operators
Logical operator
Assignment operator
Ternary operator
Operator operation Symbol
Operator | Description |
---|---|
Addition | |
- | Subtraction |
* | Multiplication |
/ | Division |
Remainder (modulo) | |
Auto-increment | |
Auto-decrement |
- Prefix auto-increment and auto-subtraction method (a,--a): Perform auto-increment or auto-decrement operation first, and then perform expression operation.
- Suffix auto-increment and self-subtraction method (a,a--): Perform expression operation first, and then perform auto-increment or self-decrement operation.
Description | |
---|---|
Check if the values of the two operands are equal, if so the condition is true | |
Check if the values of the two operands are equal, if the values are not equal then the condition is true | |
Check if the value of the left operand is greater than the right The value of the operand, if so then the condition is true | |
Checks whether the value of the left operand is greater than or equal to the value of the right operand, if so then the condition is true | |
Description | ||
---|---|---|
And, if the corresponding bits are all 1, the result is 1, otherwise it is 0 | ||
Or, if the corresponding bits are all 0, the result is 0, otherwise it is 1 |
||
XOR, if the corresponding bit values are the same, the result is 0, otherwise it is 1 | ||
Negation, the bitwise negation operator flips each bit of the operand, that is, 0 becomes 1, and 1 becomes 0 | Bitwise left shift operator. The left operand is shifted left by the number of digits specified by the right operand | |
Bitwise right shift operation symbol. Shift the left operand bitwise right by the number of digits specified by the right operand | ||
##\ | \||||||||||||||||||||||||||||||||||||||
Logical OR. If either of the two operands is true, the condition is true | Logical negation. Used to invert the logical state of the operand. If the condition is true, the logical NOT operator will give false | |||||||||||||||||||||||||||||||||||||
The order of logical judgment is from left to right. When making logical judgments, there are ordinary AND (&), ordinary OR (|) and short-circuit AND (&&), short-circuit OR (||). Their differences are: 使用普通与、或操作时,所有的判断条件都会执行; 使用短路与运算时,只要有一个判断返回了false,后续的判断就不再执行。 使用短路或操作时,只要有一个判断返回了true,后学的判断就不再执行。 Assignment operation
|
The above is the detailed content of Detailed introduction to Java basic operators and logic control (with examples). For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

mPDF
mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

VSCode Windows 64-bit Download
A free and powerful IDE editor launched by Microsoft

EditPlus Chinese cracked version
Small size, syntax highlighting, does not support code prompt function

MantisBT
Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

SublimeText3 Chinese version
Chinese version, very easy to use