Java Programming thought Learning (ii) operator

Source: Internet
Author: User

1. Object "Assignment": When manipulating an object, we are actually manipulating the reference to the object. So if you assign an object to another object, you are actually copying the reference from one place to another. (There is an association between objects, but this association can be changed.) )

2. = = and! = Compare a reference to an object. The default behavior of the Equals () method is to compare references, and if you override the Equals () method in the object that defines the class, you can achieve the effect of comparing the actual content of the object to equality.

3. The "with" (&&), "or" (| |), "NON" (!) actions can only be applied to Boolean values. Unlike in C and C + +, you cannot use a non-Boolean value as a Boolean value in a logical expression. Note that if a Boolean value is used where the String value should be used, the Boolean value is automatically converted to the appropriate text form.

4. If the values of char, byte, or short are shifted, they are converted to the int type before the shift is made, and the resulting result is also a value of type int.

5. When a float or double is converted directly to an integer value, the number is always truncated. If you want to get rounded results, you need to use the round () method in Java.lang.Math.

6. As long as the type is smaller than int (that is, char, Byte, or short), the values are automatically converted to int before the operation. Typically, the largest data type that occurs in an expression determines the data type of the final result of the expression. Float*double=double,int*long=long.

7. Java does not have sizeof because all data types are the same size in all machines.

Java Programming thought Learning (ii) 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.