Thinking in Java Note 3 OPERATOR

Source: Internet
Author: User
  • Java Operators
Almost all operators can only operate on basic types, but "=", "= ","! = "All objects can be operated. The string class supports "+", "+ = ".
  • Assignment
When performing operations on an object, the Operation references the object. Therefore, assigning an object to another object actually copies the reference from one place to another. For example, if C = D, both C and D point to the object that D points.
  • Arithmetic Operators
% Evaluate the remainder,/Integer Division will directly remove the decimal places of the result, instead of rounding (math. Round ())
  • Auto increment and decrease
++ I (increasing prefix) and -- I run the calculation first, then generate the value. I ++ and I -- are values, and then perform the operation.
  • Relational operators
= And! = Compare objects or basic type values. Equals () compares the actual content of an object.
  • Logical operators
Unlike C ++, non-boolean values cannot be used as boolean values in logical expressions. For example, int I = 9; if (I) // error if (I! = 0) // correct
  • Direct constant
When using a direct constant, you can add a suffix to indicate its type. The binary number does not have a direct constant representation method. You can use the static tobinarystring () method of integer long.
  • Bitwise Operator
  • Shift Operator

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.