java.lang.Object | +----HelloWorldJavadoc
- public class HelloWorldJavadoc
- extends Object
class HelloWorldJavadocis an application that prints the phrase hello, world to the standard output stream. This class must be stored in a file named HelloWorldJavadoc.java.To compile:
Every java application must have a
public staticmethod (i.e. function) named
main. The method doesn't return anything (i.e. its return type is
void) and it receives one parameter: an array containing zero or more handles to
Stringobjects. Java is a case sensitive language; therefore,
MAINare unique names.
By convention, class names start with an uppercase letter. If the name consists of multiple words, then each subsequent word begins with an uppercase letter (e.g. StreamTokenizer, MenuBar, HelloWorldJavadoc).
This program uses the
println()method which writes the contents of a
Stringobject to the standard output stream followed by a newline character. A similar method named
print()could be used, but it doesn't print a newline.
At program startup (i.e. prior the the
main()method being invoked), two output streams (standard out and standard error) and one input stream (standard in) are opened. Access to these I/O streams is obtained via statically defined objects located in the
Systemclass. The output objects have the names
err, respectively, and they are objects of type
PrintStream. The input object has the name
inand it is of type
InputStreamare classes found in the
Systemclass defines methods that provide a platform independent interface to system functions. All the methods and variables of the class are static (i.e.
Systemobjects cannot be created).