What to learn in 2015.7.29

Source: Internet
Author: User

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

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.