A Closer Look at Helloworld: Explanation of An Application
A Closer Look at Helloworld: Explanation of An Application
A Closer Look at Helloworld: Explanation of An Application
32 GETTING STARTED
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