<java Basics > Operators <7>

Source: Internet
Author: User
Tags arithmetic operators logical operators mathematical functions

operators are special symbols that are used primarily for mathematical functions, some types of assignment statements, and logical comparisons.
Public class test{//Create Class
         /**
* Assignment Operator: The assignment operator is denoted by the symbol "=", and its function is to assign the right operand to the left operand.
* arithmetic operators: arithmetic operators to sign "+ (plus)", "-(minus)", "* (multiply)", "/(except)", "% (redundancy)" means that these operators are familiar, see the following usage is good.
* Self-increment and decrement operators: the function of the self-increment and decrement operators is to increase the value of the variable by 1 or minus 1, and the operation data must be a XXX or floating-point variable.
* Comparison operators: The comparison operator is denoted by the symbol "> (greater Than)", "< (less than)", "= = (equals)", ">= (greater than equals)", "<= (less than equals)", "! = (unequal)".
* I believe this is also a look at everyone to understand, to note that the result of the comparison operator is a Boolean, set to True, otherwise false.
* Logical operators: Logical budget pay with symbols "&&, & (with, note here are two symbols can be used)", "| | (OR) ","! (non) ".
* The data for the logical operator operation must be Boolean, as shown in the following code.
          */
Public static void Main (string[] args) {//Main method
int number1 = 1; declares an int variable and assigns a value of 1
int number2 = 2; declares an int variable and assigns a value of 2
int number3 = number2 + number1;//Here is the arithmetic operator, this time Number3 will be equal to 3, operator substitution, you understand.
int number4 = 12 10;//Here is the remainder, here nunber4 will be equal to 2, understand it.
++number1 (--number1); The self-increment operator is used here, which means that the number1 is added (minus) 1 before the variable number1 is used.
number1++ (number1--); Indicates that after using the variable number1, the number1 is then added (minus) 1.
Boolean RESULT1 = number1<number2;//The comparison operator is used here, or false if it is set to true.
//The following is a logical operator, which means, The representative means that either side of the set is true and is not set to false.
Boolean result2 = ((number1<number2) | | (Number2>number1));
         }
}

PS: If you have a knowledge of the binary system, you can learn the "bit operation" by Baidu itself.


<java Basics > Operators <7>

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.