6.5. Some Simple Java Programs

Following are some very basic programs to give a flavor of the language. Don't worry about understanding every detail; we'll go over things step by step later on. But it is a good idea to run these programs. Try making a few changes after successfully executing the original versions.

The Basic Hello World Application

“Application” is Java lingo for a stand-alone Java program. An application must contain a class whose name exactly matches the filename (including case) and that contains a main method declared public static void with an a single string array as an argument. A string array can be declared String[] argName, or String argName[]. Listing 6.1 presents a simple application that prints “Hello, world.” when ...

Get Core Web Programming, Second Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.