Java Reference
In-Depth Information
LISTING 1.2
//********************************************************************
// Lincoln2.java Author: Lewis/Loftus
//
// Demonstrates a poorly formatted, though valid, program.
//********************************************************************
public class Lincoln2{ 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.
Taking white space to the other extreme, we could write almost every word
and symbol on a different line with varying amounts of spaces, such as Lincoln3 ,
shown in Listing 1.3.
All three versions of Lincoln are technically valid and will execute
in the same way, but they are radically different from a reader's
point of view. Both of the latter examples show poor style and make
the program difficult to understand. You may be asked to adhere
to particular guidelines when you write your programs. A software
development company often has a programming style policy that it requires its
programmers to follow. In any case, you should adopt and consistently use a set
of style guidelines that increase the readability of your code.
KEY CONCEPT
You should adhere to a set of guide-
lines that establish the way you for-
mat and document your programs.
LISTING 1.3
//********************************************************************
// Lincoln3.java Author: Lewis/Loftus
//
// Demonstrates another valid program that is poorly formatted.
//********************************************************************
public class
Lincoln3
{
public
static
void
main
Search WWH ::




Custom Search