Java Foundation WORK3

Source: Internet
Author: User
Tags bitwise bitwise operators logical operators

# # #03.01_java Language Basics (Basic usage of logical operators) (master)
* A: What are logical operators
* &,|,^,!
* &&,| |
* B: Case Demo
* Basic usage of logical operators

* Precautions:
* A: Logical operators are typically used to concatenate expressions or values of type Boolean.
* B: expression: It is the Java syntax that joins a constant or variable with an operator.
* Arithmetic expression: A + b
* Comparison expression: a = = B (conditional expression)
* C: Conclusion:
* & Logic with: false is false.
* | Logical OR: TRUE if true.
* ^ Logical XOR: The same is false, and the difference is true.
* Logical non: false is true, False if not true.
* Features: An even number does not change itself.

# # #03.02_java Language Basics (logical operators && and & Differences) (Master)
* A: Case Presentation
* The difference between && and &?
* A: The end result is the same.
* b:&& has short circuit effect. The left side is false and the right side is not executed.
* & whether the Left is false or true, the right side will execute
* B: similarly | | and | The difference? (Student self-study)
* C: Who is used in development?
* &&,| |,!

# # #03.03_java Language Basics (Basic usage of bitwise operators 1) (learn)
* A: What are bitwise operators
* &,|,^,~,>>,>>>,<<
* B: Case Demo
* Basic usage of bitwise operators 1

* Usage of &,|,^,~
* &: 0 is 0
* |: There are 1 1
* ^: same 0, different 1
* ~: Bitwise REVERSE

# # #03.04_java Language Basics (features of bitwise XOR OR operator and interview questions) (master)
* A: Case Presentation
* Characteristics of bitwise XOR OR operator

* ^ Features: one data to another data bit XOR or two times, the number itself is unchanged.

* B: Interview questions:
* Please implement the exchange of two integer variables yourself
* Note: In the course of future lectures, I did not explicitly specify the type of data, the default int type.

# # #03.05_java Language Basics (Basic usage of bitwise operators 2 and interview questions) (learn)
* A: Use of case presentation >>,>>>,<<:
* <<: Left to left highest bit discarded, right 0
* >>: Right shift highest bit is 0, left side is 0; Max is 1, left side is 1
* >>>: Unsigned right shift whether the highest bit is 0 or 1, the left side is 0
* The results of 2 * 8 are calculated most efficiently

# # #03.06_java Language Basics (Basic usage of ternary operators) (master)
* A: The format of the ternary operator
* (relational expressions)? Expression 1: Expression 2;
* B: Execution flow of ternary operators
* C: Case Demo
* Get the maximum value in two numbers

# # #03.07_java Language Basics (practice of ternary operators) (master)
* A: Case Presentation
* Compare whether two integers are the same
* B: Case Demo
* Get the maximum value from three integers

# # #03.08_java Language Basics (Basic format for keyboard entry) (master)
* A: Why use the keyboard to enter data
* A: To make the program's data more consistent with the developed data
* B: Make the program more flexible
* B: How to implement keyboard input?
* Format first.
* A: Guide package
Format
* Import Java.util.Scanner;
Location
* Above class.
* B: Create keyboard Entry Object
Format
* Scanner sc = new Scanner (system.in);
* C: Get data from objects
Format
* int x = Sc.nextint ();
* C: Case Demo
* Keyboard input 1 integers, and output to the console.
* Keyboard input 2 integers, and output to the console.

# # #03.09_java Language Basics (Keyboard entry exercises 1) (master)
* A: Case Presentation
* Keyboard Input Exercise: Keyboard input two data, and the two data summed, output its results
* B: Case Demo
* Keyboard Input Exercise: Keyboard input two data, get the maximum value in both data

# # #03.10_java Language Basics (Keyboard entry exercises 2) (master)
* A: Case Presentation
* Keyboard Input Exercise: Keyboard input two data, compare whether the two data is equal
* B: Case Demo
* Keyboard Input Exercise: Keyboard input three data, get the maximum value of these three data

# # #03.11_java Language Foundation (sequential structure statement) (learn)
* A: What is a Process Control statement
* Process Control statement: Can program the execution process.
* B: Classification of Process Control statements
* Sequential structure
* Select structure
* Cyclic structure
* C: Execution Process:
* FROM top to bottom, execute in turn.
* D: Case Demo
* Output a few words to see the effect can be

# # #03.12_java Language Foundation (SELECT Structure if statement format 1 and use) (master)
* A: Select the classification of the structure
* If statement
* Switch statement
* B:IF statements are available in several formats
* Format 1
* Format 2
* Format 3
* Format of the C:IF statement 1
*
if (comparison expression) {
Statement body;
}
* D: Execution Process:
* The value of the comparison expression is evaluated first to see if its return value is true or false.
* If true, executes the statement body;
* If False, the statement body is not executed;

# # #03.13_java Language Basics (SELECT Structure if statement considerations) (Master)
* A: Case Presentation
* A: Compare expressions whether simple or complex, the result must be a Boolean type
* B:IF Statement Control Statement Body if it is a statement, curly braces can be omitted;
* If it is more than one statement, you cannot omit it. Never omit the suggestion.
* C: Generally speaking: there is no semicolon on the left curly brace, there is no left brace for the semicolon

# # #03.14_java Language Foundation (SELECT Structure if statement format 2 and use) (master)
* Format of the A:IF statement 2
*
if (comparison expression) {
Statement body 1;
}else {
Statement body 2;
}
* B: Execution Process:
* The value of the comparison expression is evaluated first to see if its return value is true or false.
* If true, executes the statement body 1;
* If False, executes the statement body 2;
* C: Case Demo
* A: Get a larger value from two data
* B: Determine whether a data is odd or even, and whether the output is odd or even

* Note: Else there is no comparison after the expression, only if there is.

# # #03.15_java Language Foundation (if statement format 2 and ternary conversion problem) (master)
* A: Case Presentation
* If statement and ternary operator complete the same effect
* B: Case Demo
* The difference between an if statement and a ternary operator

* Ternary operators can be implemented using the IF statement. Conversely, it is not established.

* When does the IF statement implementation not use ternary improvement?
* Cannot when the IF statement control operation is an output statement.
* Why? Because the ternary operator is an operator, the operator should have a result, rather than an output, after the operation.

# # #03.16_java Language Foundation (SELECT Structure if statement format 3 and use) (master)
* Format of the A:IF statement 3:
*
if (comparison expression 1) {
Statement body 1;
}else if (comparison expression 2) {
Statement body 2;
}else if (comparison expression 3) {
Statement Body 3;
}
...
else {
Statement body n+1;
}
* B: Execution Process:
* First evaluates the comparison expression 1 to see if its return value is true or FALSE,
* If true, executes the statement body 1,IF statement end.
* If False, then the comparison expression 2 is evaluated to see if the return value is true or FALSE,

* If true, executes the statement body 2,IF statement end.
* If False, then the comparison expression 3 is evaluated to see if the return value is true or FALSE,

* If all is false, execute the statement body n+1.
* C: NOTE: The last else can be omitted, but it is not recommended to omit, you can prompt for error values outside the range

# # #03.17_java Language Basics (Choose Structure if statement Format 3 exercises) (master)
* A: Exercise 1
*
Requirements: Keyboard input A score, judge and output grade.
90-100 Excellent
80-89 Liang
70-79 in
60-69 and
0-59 Difference

* B: Exercise 2
Needs
* Keyboard input x value, calculate y and output.

* x>=3y = 2 * x + 1;
* -1<x<3y = 2 * x;
* x<=-1y = 2 * x-1;

# # #03.18_java Language Foundation (select nested use of structure if statement) (master)
* A: Case Presentation
* Requirements: Get the maximum value from three data
* Nested use of the IF statement.

# # #03.19_java Language Basics (format of the Select Structure switch statement and its interpretation) (master)
* Format of the A:switch statement
*
switch (expression) {
Case value 1:
Statement body 1;
Break
Case Value 2:
Statement body 2;
Break
...
Default
Statement body n+1;
Break
}

* Format explanation of the B:switch statement
* C: Face question
* Can byte be used as a switch expression?
* Can long be used as a switch expression?
* Can string be used as a switch expression?
* C: Execution process
* Evaluates the value of an expression first
* Then match the case, and execute the corresponding statement if there is one, otherwise execute the default control statement

# # #03.20_java Language Basics (exercises to select structure switch statements) (master)
* A: Integer (given a value, the output corresponds to the day of the week)

# # #03.21_java Language Basics (Considerations for choosing a structure switch statement) (master)
* A: Case Presentation
* A:case can only be a constant, cannot be a variable, and the value after multiple case cannot appear the same
* Can B:default be omitted?
* Can be omitted, but is not recommended, because its role is to give a hint to the incorrect situation.
* Special case:
* Case can fix the value.
* A,b,c,d
* Can c:break be omitted?
* The last one can be omitted, the other best not to omit
* There is a phenomenon: case penetrating.
* Finally we recommend not to omit
* D:default must be at the end?
* No, it can be anywhere. But the suggestion at the end.
* End condition of E:switch statement
* A: It's over when you hit a break
* B: Execution to switch closing curly brace is over.

# # #03.22_java Language Basics (choose structure Switch Statement Practice) (master)
* A: Look at the program to write the results:
*
int x = 2;
int y = 3;
Switch (x) {
Default
y++;
Break
Case 3:
y++;
Case 4:
y++;
}
System.out.println ("y=" +y);

* B: Look at the program to write the results:
*
int x = 2;
int y = 3;
Switch (x) {
Default
y++;
Case 3:
y++;
Case 4:
y++;
}
System.out.println ("y=" +y);

# # #03.23_java Language Basics (Choose the difference between a struct if statement and a switch statement) (master)
* A: Summarize the respective usage scenarios for the switch statement and the IF statement
* switch is recommended for determining fixed values
* If it is recommended to determine the interval or range of time with
* B: Case Demo
* The following requirements are implemented using switch statements and if statements, respectively:
* Keyboard entry month, output corresponding to the season

# # #03.24_DAY03 Summary
Summarize today's knowledge points once again.

Java Foundation WORK3

Related Article

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.