Read tij-3 Control Program Flow

Source: Internet
Author: User

Introduction to programming thinking in Java

Think in Java chapter 3rd control program process

This chapter should not involve "ideas". Introduction to programming (Java) · 0. 2.2. Compress related content into a section titled "Chapter 1 function abstraction · 3. 2. Implementation.

3.1 Use Java Operators

Side effects: [p98: side effects are generally used for operations (expressions). An operation/expression has "Side effects". When you evaluate the value of this expression, it will change one or more data of the program, so that when you evaluate the expression again, different results may be obtained. In fact, four expression statements in Java, such as value assignment, auto-increment and auto-subtraction, method call, and object creation, may cause side effects. The side effects of the method are discussed here .......]

3.1.1 The priority is very concise

3.1.2 assignment [This is not a simple topic, so we will leave it for further discussion in chapter 12th. That chapter focuses on aliases .] "Alias" seems to be a very simple problem. Wait and see.

3.1.3 what is the regular expression inserted in the arithmetic operator?

3.1.4 auto increment and decrease [P105 when x ++, ++ X is a part of a larger expression, assuming X is 2, then the value of X ++ expression is 2, the value of the ++ x expression is 3.] It is easy to understand.

3.1.5 Relational operators [the Relational operators = and! = Also work with all objects, but their meaning often confuses the first-time Java programmer.] It was originally very simple and could not be found by the author himself. = And! = Whether it is for the basic or reference typeVariable, JudgeValueEqual or not. [If two references are equal, they point to the same object. Generally, (new A () = new A () is always false, because the two created objects have their own references .] UseNot rewrittenObject. Equals () method?

3.1.6 logical operators

3.1.7 bitwise operators I separate bitwise operations in Chapter 12th bitwise operations. bitwise operations are widely used in assembly languages. [The boolean type isTreated as a one-bit value, So it is somewhat different.] the Java language never looks at Boolean like this.&, | And ^ are overloaded operators.. Java "logical" operators has 6, baby.

3.1.8 in the example of the shift operation of the shift operator, it is best to use the expression 0x8000_0000 added by Java 7.

3.1.9 place the ternary if-else operator in 3.2.3 If statement.

3.1.10 the only place where the comma operator needs to be used in Java is the for loop.

3.1.11 string operator + although Operator Overloading wowould have been much simpler to implement in Java than it was in C ++, this feature was still considered too complex

3.1.12 general operator operation rules common pitfalls when using operators: Why parentheses?

3.1.13 shape Operators

Why does literals talk about text here? 'E' refers to the base of natural logarithms. Why can't e be short for exp?

3.1.14 JAVA does not have "sizeof" redundant

3.1.15 review calculation sequenceUse one sentence to help remember, You can consider

The 3.1.16 operator sums up a bad routine and uses 8 pages!

3.2 execute control if-Else, while, do-while, switch. I have a question, why should Tsinghua University Press change if-Else If... ElseIs my primary school language taught by a PE teacher ?, I am not used to if... Else if... Else.

3.2.1 true and false

3.2.2 If-Else

3.2.3 repeated/iteration translation is certainly not a computer. Iteration

3.2.4 do-while [traditional procedural versions like C require that all variables be defined at the beginning of a block so that...] C11 does not need to define all variables at the beginning of the block. 1. the comma operator is a separator, which is not a problem. Java can regard it as a replacement.

3.2.6 interruption and Continuation

1. the notorious "Goto" [for Java, the only place that uses tags is before the loop statement .] Syntactically, a tag can be used to add an identifier for any statement (except a declaration statement.

Case: If (Level = 10) {PLN ("excellent"); break case;} case: If (Level = 9) {PLN ("excellent "); break case;} case: If (Level = 8) {PLN ("good"); break case;} case: If (Level = 7) {PLN ("good"); break case;} case: If (Level = 6) {PLN ("pass"); break case;} If (level <6) {PLN ("fail ");}
You can execute the above Code or change it to a standard switch statement (note: the case in the code is not a case ).
3.2.7 Switch


An uninteresting chapter.


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.