Web-android Engineer first-5-4 using Eclipse debugger

Source: Internet
Author: User

Source: http://www.imooc.com/video/1627

IDE Breakpoint Debugging Features

For example, the previous program, wrote the wrong, become the following

1  PackageCom.imooc;2 ImportJava.util.Scanner;//written behind the package3 4  Public classHelloWorld {5      Public Static voidMain (string[] args) {6Scanner input=NewScanner (system.in);//Create a Scanner object7System.out.print ("Please enter exam results information:");8         9         intScore = Input.nextint ();//get user-entered scores and save them in a variableTen          One         //variables are saved in addition to the number of times A         intCount = 0; -  -         //print output plus pre-score theSystem.out.println ("Pre-bonus score:" +score); -          -         //as long as the score is less than 60, the loop performs the add-on operation and counts the number of points -          for(; score + count <= 60; ) { +count++; -         } +                  A         //print output plus score, plus number of points atSystem.out.println ("Bonus score:" + (score +count)); -System.out.println ("A total of" +count+ "Times!")); - System.out.println (); -     } -}

The result becomes:

Please input test results information: 8 Total added !

In fact, the score is not more than 61.

You can use the IDE to debug breakpoints at this time

Steps:

1. Set breakpoints

For example, set a breakpoint on the line where the loop is judged

To set a breakpoint, double-click on the left side of the row

For example, below the 18-row position, when you double-click Done, you can see that the position becomes a dot

Then click on the Debugger button, enter 53 after entering,

When you are prompted to open the Debug view (Confirm perspective Switch), you can tick the Remember option (Remember my decision) and click YES

The debug view opens as follows:

The source code page can see that the run-to-breakpoint position is paused: (the line code was not run the first time to the line breakpoint)

Single-Step Debugging:

Step over: The corresponding button is, can be single-step debugging

Once clicked, the current line runs and runs to the next line

Watch the Variable window view at this time

Continue stepping at this time, observing variable changes and results

Web-android Engineer first-5-4 using Eclipse debugger

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.