Java-language operators and expressions

Source: Internet
Author: User
Tags arithmetic operators

Operators in Java:

Arithmetic operators: +,—, *,/(except for rounding),% (modulo redundancy), + + (self-increment),—— (self-decrement)

Negative operator: =,+=,-=,/=,%=

Relational operators: The >,<,>=,<=,==,!= relational operator is a comparison of the operands on both sides, and the result is always Boolean

Logical operator:! , &,|,^,&&,| |

Bitwise operator::&,|,^,~,>>,<<,>>>

String Join operator: + In addition to being used to concatenate strings, you can also concatenate strings with other data types into a new string such as String s= "X" + 123

Trinocular operator: X? Y:z

X is a Boolean expression that evaluates the value of x first, and if true, the result of the entire trinocular operation is the value of the value of the expression y otherwise Z.

such as: int score=45;

String type=score>=60? " Pass ":" Failed ";

An expression

1. An expression is a sequence of operators and operands that conform to a certain grammatical rule

2. Type and value of an expression

The result of operations on operands in an expression is called the value of the expression

The data type of the value of the expression is the type of the expression

3. Order of operation of expressions

You should first follow the precedence of the operators from highest to lowest

Operators with the same precedence are performed in a pre-agreed binding direction

              

Java-language operators and expressions

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.