Java Lab report One: Familiarity with the Java development environment

Source: Internet
Author: User

Java Lab report One: Java familiarity with the development environment

20135322 Zheng Wei

Experimental requirements:

1. Compiling and running a simple Java program using the JDK

2. Edit, compile, run, and debug Java programs using Eclipse

Experimental content

(i) Java program Development under command line

(ii) Development and commissioning of Java programs under Eclipse

(iii) exercises (implemented via command line and Eclipse two, practice debugging under Eclipse)

5. Realize the function of all prime numbers between the 1-n integers and test them.

Experimental process

Experiment One:

Open the command line through the Xface software by running the window, via the command line, by gedit the file name. java, or vim file name. Java, into the Java program's codec interface. After writing the code saved, pass the javac-d. File name. java compiler program. Enter Java Scn.hello to run the compiled program.

Experiment Two:

Programming with Eclipse. Note To save the established class to the package folder. Write the development process. Focus on debugging the program, click Window->open perspective->debug to open the debug view.

Set breakpoints, and in front of where you want to set breakpoints, double-click the section that precedes the number of rows to set breakpoints quickly.

debugging shortcut keys are F11, single-step debugging, enter the function shortcut key is F5, do not enter the function shortcut key F6, general debugging do not enter the function, when the function problem, then enter the function.

To debug at a specified location, use the Resume function of the shortcut key for F8.

You can view the value of a variable at this time by moving the mouse over the variable.

Conditional breakpoints, which are typically used in loop statements. Right-click on the left side of the statement line you want to debug, select "Breakpoint Properties ..." and enter the desired loop condition

Experiment three: Realize the function of finding all prime numbers between positive integers 1-n and testing.

Experimental analysis: From the experimental requirements can be extracted, the experiment needs (1) to determine whether a number is an exponent (2) output 1-n between prime numbers (3) n is a variable, should have user input.

Analysis of the 2nd requirement can be achieved on the basis of inheriting the 1th requirement.

Write the parent class to determine whether it is a prime number;

Writes a subclass, on the basis of inheriting the parent class, outputs the prime number between the 1-n;

In the main function, call the input function by calling the Java package, and enter N.

The problems and solutions encountered in the experiment.

The problem encountered in the experiment.

Problem: After writing the code, then enter the compilation command is not responding, does not appear the Blue line path

Workaround: Close the Code Editor, the command line immediately reaction, re-open the original code, compile.

In addition, the problem to note is: Compile the Java file with the package name, the location of the well-known package folder store, "." Refers to saving to the current folder. You should add a space after-D and then add ".". is a syntax error.

Experiment Two

debugging problems, there is a breakpoint option cannot be found.

Solution: Ask the classmates who have done it.

Experiment three problems.

Use arrays to do Fibonacci sequences, but don't know how many numbers to output in a topic

Resolution: Defines an array of length 20, outputting the first 20 Fibonacci sequences.

Experimental Harvest

This experiment, to me the most influential is to learn to debug the program in Eclipse, I think this is every programmer must learn, through the debugging of the code, the combination of theory and practice, let me debug the code of the process more familiar with, and applied to the experiment three, to debug code. In the experiment three, I did not see the topic, only in Eclipse run the code, but forget to run in the command line, although this error, as long as redo it, but I think in reading or doing anything to maintain a careful attitude. The internet is slow, but to do things, be patient.

Java Lab report One: Familiarity with the Java development environment

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.