Think in Java Chapter 3 operator Chapter 4 control Execution Process

Source: Internet
Author: User

Chapter 3 Operators

The classpath environment variable is used to find the class. Java file s required during compilation.

1. Relational operators
Reference comparison: = is used to determine whether the referenced object (the object's memory address) is the same.
Object comparison: equals (). If the content of the two objects is the same, the equals () function must be overwritten.
&, | ,! It can be used only for Boolean variables.
For example, int I ;! (I <10) // correct! I // wrong

2. Short Circuit
Once the value of the entire expression is clearly determined, the remaining part of the expression is no longer calculated.
For example, test (1) & Test (2) & Test (3). If test (1) returns false, test (2) and test (3) are not executed)

3. >>> unsigned right shift operator
No matter whether the positive or negative values are shifted to the right, only 0 is inserted at the high position.

4. If-Else
Boolean-exp? Value1: value2

4. type conversion Operators
In addition to the boolean type, Java allows you to convert a basic type to any other basic type.
For example, int I; long l = (long) I;

Chapter 4 control Execution Process

1. foreach
Used for arrays and containers. For example, float f [] = new float [10];
For (float X: F)
For (char C: "Hello world! ". Tochararray ())

2. Break and continue are used for the for and while loops.

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.