----operators in the Java language

Source: Internet
Author: User

DAY05----operators in the Java language

First, the operator Overview:

The use of operators is used in every development language, and there are different usage rules in different languages. With the operator we can think of the MySQL database operators, these are similar, perhaps some in use is not the same. Here's a look at the operators in Java.


Second, Operator:

1. Arithmetic operators:

Mainly include: Add, subtract, multiply, divide, take surplus (%), self-add (+ +), self-reduction (--)

2. Assignment operators:

is the equal sign (=)

3, Bitwise operators:

Mainly includes:&, |, ~, ^, <<, >>, >>>

4. Comparison operators:

Mainly includes:>, >=, <, <=, = =

5. Logical operators:

Mainly includes:&&, &, | |, |,! ^

Iii. Precedence of Operators

operator Description operator
Separator . [ ]  ( )  { } , ;
Monocular operator + +--~!
Forcing type conversion operators (type)
Multiply, divide, and seek redundancy *  /  %
Add, Subtract +  -
Shift Operators << >> >>>
Relational operators < <= > >= instanceof
Equivalence operators ==  !=
Bitwise-AND &
Bitwise XOR OR ^
Bitwise OR |
Conditions and &&
Conditions or ||
Trinocular operation ?:
Assign value = + = = *=/= &= |= ^=%= <<= >>= >>>=


Iv. examples

Package www.dzx.c1; public class OPerators {public static void main (string[] args) {//judgment positive even int a = 10;if (a>0 && a%2==0) {System.out . println ("This number is a positive even!") ");} else {System.out.println ("This is not even!") ");};/ /Judging leap years int year = 2004;if (Year%400==0 | | (year%4==0 && year%100!=0)) {System.out.println (year+) is a leap year! ");} else {System.out.println (year+) is not a leap year! ");} Self-increment and decrement int b = 20; System.out.println (b++); System.out.println (++B); System.out.println (b--); System.out.println (--b);}}


V. Concluding remarks:

Here we have learned the operator, you have to use it in the instance to continue to use, constantly to review.

This article from "Lonely One Night" blog, reproduced please contact the author!

----operators in the Java language

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.