Eclipse learning 2

xiaoxiao2021-03-06  46

Eclipse learning 2

To create a simple example to see how eclipse writes Java code: package com.test.ex01;

To create a simple example to see how eclipse writes Java code: package com.test.ex01;

/ ** * @Author kevin lee * * / public class helloworld {

Public static void main (string [] args) {system.out.println ("Hello, World!");}}

First, all Java codes in Eclipse must be included in Java Project, so the first step in writing code in Eclipse is to create Java Project.

The steps to create Java Project are as follows: File - "New -" Project (right click in Package Explorer, and select New - "Project).

Then will pop up the New Project dialog as follows:

【image】

This is asking for a Wizard, select Java Project, and then click Next. The Wizard, which creates Java Project.

【image】

Here is the HelloApp in Project Name, and then click Finish.

The next is to create a Java class file. The steps to create a Java Class are as follows: File - "New -" Class (or right-click Package Explorer and select New - "Class).

A New Java Class dialog box pops up. as follows:

【image】

Fill in the Package column, and represent the Java package. Fill in HelloWorld in Name, pay attention to the Name and the file name in Java. And check "Public Static Void Main (String [] args" one, which automatically creates an empty main () method. Then click Finish.

At this time, Eclipse automatically generates the HelloWorld.java source file. Figure

【image】

Then add the corresponding code line in the main () method: system.out.println ("Hello, World!"); This time, Eclipse has Code Assist to help reduce the input of the code. For example, enter system. After you see a list, you can select the corresponding code. At the same time, "After", Eclipse will also be added automatically. "

【image】

As shown in the figure, the statement lacks a semicolon, and Eclipse will automatically represent in the wrong wave line in the wrong place. A prompt will appear when the mouse moves there.

Execute this program, select RUN- "Run as-" Java Application, then display messages in Console: "Hello, World!". Figure:

【image】

转载请注明原文地址:https://www.9cbs.com/read-71498.html

New Post(0)