0% found this document useful (0 votes)
3 views1 page

A Closer Look at Helloworld: Explanation of An Application

Download as pdf or txt
Download as pdf or txt
Download as pdf or txt
You are on page 1/ 1

05-1.

fm Page 32 Friday, March 2, 2001 12:54 AM

32 GETTING STARTED

A Closer Look at HelloWorld


Now that you’ve compiled and run your first program, you may be wondering how it works
and how similar it is to other applications or applets. This section will first take a closer look
at the HelloWorldApp application and then the HelloWorld applet. Be aware that the follow-
ing chapters, Object-Oriented Programming Concepts (page 45) and Language Basics (page
65), will go into much more detail than is presented in this section.

Explanation of an Application
Let’s dissect the HelloWorldApp application. First, we will look at the comments in the code
before we touch on programming concepts, such as classes and methods.

/**
* The HelloWorldApp class implements an application that
* displays "Hello World!" to the standard output.
*/
public class HelloWorldApp {
public static void main(String[] args) {
System.out.println("Hello World!"); //Display the string.
}
}

Comments
Comments make your code more readable; they help explain your code to others and serve
as reminder to yourself when you maintain your own code. The Java programming language
supports three kinds of comments:
/* text */
The compiler ignores everything from the opening /* to the closing */.
/** documentation */
This style indicates a documentation comment (doc comment, for short). As with the
first kind of comment, the compiler ignores all the text within the comment. The SDK
javadoc tool uses doc comments to automatically generate documentation. For more
information on javadoc, see the tool documentation.1
// text
The compiler ignores everything from the // to the end of the line.

1
You can find the tool documentation online: http://java.sun.com/j2se/1.3/docs/tooldocs/tools.html

You might also like