2015.7.29Learning ContentASwitchSelect Structure1.Review
how to produce a random number in Java
Math.random () random number range:0 to 1, can fetch 0, less than 1
02.equals ():
In Java , if you compare two strings with = = , you'll get an error, so we'll just use the equals method when we compare the string types.
2.SwitchSelect Structure
Switch (char/int) {
Case 1:
Statement
Break
Case 2:
statement 2
Break
Default
Default Statement
Break
}
3.switchNote the point:
* 01. There are only two types of expressions in parentheses: int , Char
* 02.case Branch values cannot be the same
* 03.case and break must appear in pairs
* 04.default position does not affect the running result
* the contents of the default block are executed only when there are no configuration items in the case
05.switch Statements compare only once
4.Exception Handling
Use Input.hasnextint () to determine whether the content entered by the user is an integer
Two The Loop structure whileand theDo-whileLoops1.whileLoops
while ( condition ) {
Loop Body
}
Cases:
int num=1;// initial variable
while (num<=100) {// loop condition
System.out.println (" Good study, day up ");// loop body
num++;// Changing the value of an iteration variable
}
All loops must have four elements:
Initial Variables
The condition of the cycle .
The body of the loop .
the value of the iteration variable must be changed
2.Program Debugging(1).Breakpoint Debugging steps:
Set breakpoints
Start debugging
Single Step operation
After debugging is started, the code line that runs to set breakpoints stops, click F6 to run the program and watch the program run
Observing variables
You can see the current value of a variable in the variables view in the step run
Discover problems
Fix code, rerun, fix problem
(2).The purpose of program debugging:identify causes of defects and fix defects(3).the main methods of program debugging: Setting breakpoints, stepping, observing variables3.do-whileLoops
do{
Loop Body
}while ( cyclic conditions );
What to learn in 2015.7.29