![]() |
The Java Developers Almanac 1.4 |
|
e48. The Quintessential Java ApplicationThe parameters to the application are made available inargs.
This example simply prints out Hello World!.
public class BasicApp {
public static void main(String[] args) {
// Process each parameter
for (int i=0; i<args.length; i++) {
// process args[i];
}
// Output a message to the console
System.out.println("Hello World!");
}
}
Here's the command to run the program:
> java BasicApp param1 param2 ...
e50. Determining When the Application Is About to Exit e51. Computing Elapsed Time e52. Loading Native Code e53. Implementing a Class That Can Be Sorted e54. Redirecting Standard Output, and Error e55. Getting the Size of the Heap
© 2002 Addison-Wesley. |