- PC - Software - Programmering
- Java - Java
applications
Every application: - must implement the method: main(Strings[] args)
| Java applications - Hello World - from The Java Tutorial 2.ed. p. 9 |
/*
The HelloWorldApp class implements an application that
simply displays "Hello World!" to the standard output.
*/
class HelloWorldApp
{
public static void main(String[] args)
//public : allows any class to call this method
//static : a class method
//void : returns no value
//String[] args : an array of strings
// = command-line arguments,
// the first is args[0]
// NB: numberOfArgs = args.length
{ // use the System class
System.out.println("Hello World!"); // Display the string
}
}
|
Save As: HelloWorldApp.java
!case is significant!
set PATH to include \java\bin (C:\jdk\java\bin) >path c:\jdk\java\bin;%path% Compile: >javac HelloWorldApp.java The compiler creates HelloWorldApp.class Run application: >java HelloWorldApp Output: Hello World!