站内搜索: 请输入搜索关键词
当前页面: 在线文档首页 > Java Tutorial 5.0 英文版

A Closer Look at the "Hello World" Application - Java Tutorial 5.0 英文版

The JavaTM Tutorial
Previous Page Lesson Contents Next Page Start of Tutorial > Start of Trail Search
Feedback Form

Trail: Getting Started

Lesson: A Closer Look at the "Hello World" Application

Now that you've seen the "Hello World" application (and perhaps even compiled and run it), you might be wondering how it works. Here, again, is its code:
/** 
 * The HelloWorldApp class implements an application that
 * simply displays "Hello World!" to the standard output.
 */
class HelloWorldApp {
    public static void main(String[] args) {
        System.out.println("Hello World!"); //Display the string.
    }
}

Comments in Java Code

The "Hello World" application contains two comments. The first comment, at the top of the program, uses /** and */ delimiters. Later, a line of code is explained with a comment that's marked by // characters. The Java programming language also supports the familiar C-style comment, which is delimited with /* and */.

Defining a Class

Like most object oriented languages, the fundamental building block in the Java programming language is the class. This section introduces you to classes, and discusses the class definition of the "Hello World" application.

The main Method

The entry point of every application is its main method. This section discusses the requirements for this method, and shows how main is implemented in the "Hello World" application.

Using Classes and Objects

This section describes the ways in which the "Hello World" application uses classes and objects.

Previous Page Lesson Contents Next Page Start of Tutorial > Start of Trail Search
Feedback Form

Copyright 1995-2005 Sun Microsystems, Inc. All rights reserved.