Java Reference
In-Depth Information
LISTING 1.1
//********************************************************************
// Lincoln.java Author: Lewis/Loftus
//
// Demonstrates the basic structure of a Java application.
//********************************************************************
public class Lincoln
{
//-----------------------------------------------------------------
// Prints a presidential quote.
//-----------------------------------------------------------------
public static void main (String[] args)
{
System.out.println ("A quote by Abraham Lincoln:");
System.out.println ("Whatever you are, be a good one.");
}
}
OUTPUT
A quote by Abraham Lincoln:
Whatever you are, be a good one.
All Java applications have a similar basic structure. Despite its small size and
simple purpose, this program contains several important features. Let's carefully
dissect it and examine its pieces.
The first few lines of the program are comments, which start with
the // symbols and continue to the end of the line. Comments don't
affect what the program does but are included to make the program
easier to understand by humans. Programmers can and should include
comments as needed throughout a program to clearly identify the pur-
pose of the program and describe any special processing. Any written comments or
documents, including a user's guide and technical references, are called documenta-
tion. Comments included in a program are called inline documentation.
KEY CONCEPT
Comments do not affect a program's
processing; instead, they serve to
facilitate human comprehension.
The rest of the program is a class definition. This class is called Lincoln ,
though we could have named it just about anything we wished. The class defini-
tion runs from the first opening brace ( { ) to the final closing brace ( } ) on the last
line of the program. All Java programs are defined using class definitions.
VideoNote
Overview of program
elements.
 
Search WWH ::




Custom Search