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 the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.