"Java programming Idea" three, operator

Source: Internet
Author: User

Thinking in Java At the bottom, the data in Java is manipulated by using operators. Because I've mastered C and C + + before, there's not much to see in this chapter. The main idea is to understand the differences between Java and C + +. Such as:
    • String class : Supports "+" and "+ =" operations
    • The "+" operator : "+" in the SYSTEM.OUT.PRINTLN (); statement, meaning "string connection" and an attempt to convert a non-string type that is immediately followed to a string type. such as: Print ("" +i) will convert I to a string type;
    • aliasing : Execution of a=b, subsequent execution of a=c, and no impact on B, for granted. However, when you assign an object to another object, you are actually copying the reference from one place to another. This means that both references point to the same object. This "aliasing phenomenon", if you want to avoid this phenomenon, you can assign the value T1.value = T2.value; This will overwrite the object.
    • equivalence of test objects : Note the use of "= =" and Equals ()
    • logical operators : "&&", "| |", "! "Operation can only be applied with a Boolean value (this is different from C + +)
    • "Short Circuit effect": if (T1 && T2), the program will first determine the Boolean value of T1, if T1 is false, do not execute T2 directly.
    • Direct Constants : integers default to ing type, floating-point numbers are double by default, and suffixes can be added to change their type.
    • bitwise operators : "&", "|", "~", "^" These are similar to the C language, there is no change.
    • shift operator : "<<" shift Left (low 0), ">>" shift right (positive 0, negative 1), ">>>" Unsigned Right shift (both positive and negative, both in the high 0); if the char/byte/ The values of the short type are shifted, and they are converted to int type before the shift, and the resulting result is also of type int;
    • type conversion operators : In Java, for "extended conversion", do not have to display the type conversion, and the implementation of the narrowing of the transformation will face the risk of information loss, at this time, the compiler will be forced to require us to type conversion, otherwise the compilation will not pass;
        • Truncation and rounding
        • Type promotion
        • Java does not have sizeof

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.