100% found this document useful (1 vote)
47 views1 page

Lesson: A Closer Look at The "Hello World!" Application: Trail: Getting Started

qwerxc

Uploaded by

Jerry Ma
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
47 views1 page

Lesson: A Closer Look at The "Hello World!" Application: Trail: Getting Started

qwerxc

Uploaded by

Jerry Ma
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

10/31/13

Lesson: A Closer Look at the "Hello World!" Application (The Java Tutorials > Getting Started)

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:
c l a s sH e l l o W o r l d A p p{ p u b l i cs t a t i cv o i dm a i n ( S t r i n g [ ]a r g s ){ S y s t e m . o u t . p r i n t l n ( " H e l l oW o r l d ! " ) ;/ /D i s p l a yt h es t r i n g . } }

The "Hello World!" application consists of three primary components: source code comments, the H e l l o W o r l d A p pclass definition, and the m a i nmethod. The following explanation will provide you with a basic understanding of the code, but the deeper implications will only become apparent after you've finished reading the rest of the tutorial.

Source Code Comments


The following bold text defines the comments of the "Hello World!" application:
/ * * *T h eH e l l o W o r l d A p pc l a s si m p l e m e n t sa na p p l i c a t i o nt h a t *s i m p l yp r i n t s" H e l l oW o r l d ! "t os t a n d a r do u t p u t . * / c l a s sH e l l o W o r l d A p p{ p u b l i cs t a t i cv o i dm a i n ( S t r i n g [ ]a r g s ){ S y s t e m . o u t . p r i n t l n ( " H e l l oW o r l d ! " ) ;/ /D i s p l a yt h es t r i n g . } }

Comments are ignored by the compiler but are useful to other programmers. The Java programming language supports three kinds of comments:
/ *t e x t* /

The compiler ignores everything from / *to * / .


/ * *d o c u m e n t a t i o n* /

This indicates a documentation comment (doc comment, for short). The compiler ignores this kind of comment, just like it ignores comments that use / *and * / . The j a v a d o ctool uses doc comments when preparing automatically generated documentation. For more information on j a v a d o c , see the Javadoc tool documentation .
/ /t e x t

The compiler ignores everything from / /to the end of the line.

The H e l l o W o r l d A p pClass Definition


The following bold text begins the class definition block for the "Hello World!" application:
/ * * *T h eH e l l o W o r l d A p pc l a s si m p l e m e n t sa na p p l i c a t i o nt h a t
docs.oracle.com/javase/tutorial/getStarted/application/ 1/3

You might also like