Chapter 1
Chapter 1
CHAPTER
1
CREATING YOUR FIRST JAVA
PROGRAM
In this chapter, you will:
♦ Learn about programming
♦ Understand object-oriented programming concepts
♦ Learn about the Java programming language
♦ Start a Java program
♦ Add comments to a Java program
♦ Run a Java program
♦ Modify a Java program
1
1 Chapter A4758 5/3/04 10:27 am Page 2
“Based on your aptitude tests, you’re perfect for programming,” Lynn says. “Let’s get
started now. I’ll describe the basics to you.”
In addition to learning the correct syntax for a particular language, a programmer also
must understand computer programming logic.The logic behind any program involves
1
executing the various statements and procedures in the correct order to produce the
desired results. For example, you would not write statements to tell the computer
program to process data until it had been properly read into the program. Similarly, you
might be able to use a computer language’s syntax correctly, but be unable to execute a
logically constructed, workable program. Examples of logical errors include multiplying
two values when you meant to divide them, or producing output prior to obtaining the
appropriate input. Tools that will help you visualize and understand logic will be
presented in Chapter 5.
to move several files from a floppy disk to a hard disk, you can use either a typed command
at a prompt or command line, or you can use a mouse in a graphical environment to
accomplish the task. The difference lies in whether you issue a series of commands, in
sequence, to move the three files, or you drag icons representing the files from one screen
location to another, much as you would physically move paper files from one file cabinet
to another in your office.You can move the same three files using either operating system,
but the GUI system allows you to manipulate the files like their real-world paper
counterparts. In other words, the GUI system allows you to treat files as objects.
Objects both in the real world and in object-oriented programming are made up of
states and methods. The states of an object are commonly referred to as its attributes.
Attributes are the characteristics that define an object as part of a class. For example,
some of your automobile’s attributes are its make, model, year, and purchase price. Other
attributes include whether the automobile is currently running, its gear, its speed, and
whether it is dirty. All automobiles possess the same attributes, but not, of course, the
same values for those attributes. Similarly, your dog has the attributes of its breed, name,
age, and whether his or her shots are current.
A class is a term that describes a group or collection of objects with common proper-
ties. An instance of a class is a technical term for an existing object of a class.Therefore,
your red Chevrolet automobile with the dent can be considered an instance of the class
that is made up of all automobiles, and your Golden Retriever dog named Goldie is an
instance of the class that is made up of all dogs.Thinking of items as instances of a class
allows you to apply your general knowledge of the class to individual members of the
class. A particular instance of an object takes on, or inherits, its attributes from a more
general category. If a general class Dog has defined attributes and methods, they can be
passed on to a specific class Golden Retriever Dog with minimal programming effort.
If your friend purchases an Automobile, you know it has a model name, and if your
friend gets a Dog, you know the dog has a breed.You might not know the exact con-
tents of your friend’s Automobile, its current state or her Automobile’s speed or her
Dog’s shots, but you do know what attributes exist for the Automobile and Dog classes.
Similarly, in a GUI operating environment, you expect each component to have specific,
consistent attributes, such as a menu bar and a title bar, because each component inher-
its these attributes as a member of the general class of GUI components.
Besides attributes, objects can use methods to accomplish tasks.A method is a self-contained
block of program code. Automobiles, for example, can move forward and backward. They
can also be filled with gasoline or be washed, both of which can be programmed as meth-
ods to change some of their attributes. Methods exist for ascertaining certain attributes, such
1 Chapter A4758 5/3/04 10:27 am Page 5
as the current speed of an Automobile and the current status of its gas tank. Similarly, a Dog
can walk or run, eat food, and get a bath, and there are methods to determine how hungry
1
the Dog is. GUI operating system components can be maximized, minimized, and dragged.
Like procedural programs, object-oriented programs have variables (attributes) and proce-
dures (methods), but the attributes and methods are encapsulated into objects that are then
used much like real-world objects. Encapsulation refers to the hiding of data and methods
within an object. Encapsulation provides the security that keeps data and methods safe from
inadvertent changes. Programmers sometimes refer to encapsulation as using a “black box,”
or a device that you can use without regard to the internal mechanisms.A programmer gets
to access and use the methods and data contained in the black box but cannot change them.
If an object’s methods are well written, the user is unaware of the low-level details of
how the methods are executed, and the user must simply understand the interface or
interaction between the method and the object. For example, if you can fill your
Automobile with gasoline, it is because you understand the interface between the gas
pump nozzle and the vehicle’s gas tank opening.You don’t need to understand how the
pump works mechanically or where the gas tank is located inside your vehicle. If you
can read your speedometer, it does not matter how the displayed figure is calculated. As
a matter of fact, if someone produces a superior, more accurate speed-determining
device and inserts it in your Automobile, you don’t have to know or care how it operates,
as long as your interface remains the same.The same principles apply to well-constructed
objects used in object-oriented programs.
operating system. In contrast, when using other programming languages, software ven-
dors usually have to produce multiple versions of the same product (a DOS version,
Windows version, Macintosh version, Unix version, and so on) so all users can use the
program.With the Java programming language, one program version will run on all these
platforms.
Java Compiler
Java Interpreter
Computer Operating
System
For simplicity, the terms “Java program” and “program for the Java pro-
gramming language” are used interchangeably throughout this text.
Tip
The Java programming language also is simpler to use than many other object-oriented
languages.The Java programming language is modeled after the C++ programming lan-
guage. Although neither language is “simple” to read or understand on first exposure,
the Java programming language does eliminate some of the most difficult-to-understand
features in C++, such as pointers and multiple inheritance.
Tip
The text “First Java program” is a literal string of characters; that is, it is a series of
characters that will appear exactly as entered. Any literal string in Java appears between
double quotation marks, as opposed to single quotation marks as in ‘First Java program’.
Even though code is written on multiple lines for ease of reading, the literal string can-
not be broken because parts of the literal string will appear on different lines.
The string “First Java program” appears within parentheses because the string is an argu-
ment to a method, and arguments to methods always appear within parentheses.
Arguments consist of information that a method requires to perform its task. For exam-
ple, you might place a catalog order with a company that sells sporting goods. Processing
a catalog order is a method that consists of a set of standard procedures. However, each
catalog order requires information such as which item number you are ordering and the
quantity of the item desired; this information can be considered the order’s argument.
If you order two of item 5432 from a catalog, you expect different results than if you
order 1,000 of item 9008. Likewise, if you pass the argument “Happy Holidays” to a
method, you expect different results than if you pass the argument “First Java program”.
Within the statement System.out.println("FirstƒJavaƒprogram"); , the
method to which you are passing “First Java program” is named println(). The println()
method prints a line of output on the screen, positions the insertion point on the next
line, and stands ready for additional output.
The print() method is very similar to the println() method. With println(), after
the message prints, the insertion point appears on the following line. With
Tip print(), the insertion point does not advance to a new line; it remains on the
same line as the output.
The Java programming language is case sensitive; the class named System is a
completely different class from one named system, SYSTEM, or even sYsTeM.
Tip
Everything that you use within a Java program must be part of a class. When you write
public class First, you are defining a class named First.You can define a Java class
using any name or identifier you need, as long as it meets the following requirements:
■ A class name must begin with a letter of the alphabet (which includes any
non-English letter, such as α or π), an underscore, or a dollar sign.
1 Chapter A4758 5/3/04 10:27 am Page 9
■ A class name can contain only letters, digits, underscores, or dollar signs. 1
■ A class name cannot be a Java programming language reserved keyword, such
as public or class (see Figure 1-3 for a list of reserved keywords).
■ A class name cannot be one of the following values: true, false, or null.
It is a Java programming language standard to begin class names with an uppercase let-
ter and employ other uppercase letters as needed to improve readability. Table 1-1 lists
some valid and conventional class names for the Java programming language.
Table 1-1 Some valid class names in the Java programming language
Class Name Description
Employee Begins with an uppercase letter
UnderGradStudent Begins with an uppercase letter, contains no spaces, and emphasizes
each new word with an initial uppercase letter
InventoryItem Begins with an uppercase letter, contains no spaces, and emphasizes
the second word with an initial uppercase letter
Budget2004 Begins with an uppercase letter and contains no spaces
1 Chapter A4758 5/3/04 10:27 am Page 10
You should follow established conventions for the Java programming lan-
guage so your programs will be easy for other programmers to interpret and
Tip follow. This book uses established Java programming conventions.
Table 1-2 Some unconventional class names in the Java programming language
Class Name Description
employee Begins with a lowercase letter
Undergradstudent New words are not indicated with initial uppercase letters;
difficult to read
Inventory_Item The underscore is not commonly used to indicate new words
BUDGET2004 Appears as all uppercase letters
Table 1-3 Some illegal class names in the Java programming language
Class Name Description
an employee Space character is illegal
Inventory Item Space character is illegal
class class is a reserved word
2001Budget Class names cannot begin with a digit
phone# The # symbol is not allowed
In Figure 1-2, the line public class First contains the keyword class, which iden-
tifies First as a class.The reserved word public is an access modifier.An access modifier
defines the circumstances under which a class can be accessed. Public access is the most lib-
eral type of access; you will learn about public and other types of access in Chapter 3.
You enclose the contents of all classes within curly braces ({ and }). A class can contain
any number of data items and methods. In Figure 1-2, the class First contains only one
method within its curly braces.The name of the method is main(), and the main() method
contains its own set of parentheses and only one statement—the println() statement.
For every opening curly brace ({) in a Java program, there must be a corresponding closing
curly brace (}).The placement of the opening and closing curly braces is not important to
the compiler. For example, the following method is executed exactly the same as the one
shown in Figure 1-2. The only difference is that the method is organized differently. This
1 Chapter A4758 5/3/04 10:27 am Page 11
location of the curly braces is common in professional code. Usually, code in which you ver-
tically align each pair of opening and closing curly braces is easier to read and is used
1
throughout this textbook. Strive to type your code so it is easy to read.
publicƒstaticƒvoidƒmain(String[]ƒargs)ƒ{
System.out.println("FirstƒJavaƒprogram");
}
The method header for the main() method is quite complex.The meaning and purpose
of each of the terms used in the method header will become clearer as you complete
this textbook; a brief explanation will suffice for now.
In the method header public static void main(String[] args), the word
public is an access modifier, just as it is when you define the First class. In the English
language, the word static means showing little change, or stationary. In the Java pro-
gramming language, the reserved keyword static ensures that main() is accessible even
though no objects of the class exist. It also indicates that every member created for the
First class will have an identical, unchanging main() method. Within the Java program-
ming language, static also implies uniqueness. Only one main() method for the First
class will ever be stored in the memory of the computer. Of course, other classes even-
tually might have their own, different main() methods.
In English, the word void means empty. When the keyword void is used in the main()
method header, it does not indicate that the main() method is empty, but rather, that the
main() method does not return any value when it is called.This doesn’t mean that main()
doesn’t produce output—in fact, the method does. The main() method does not send
any value back to any other method that might use it.You will learn more about return
values in Chapter 3.
Not all classes have a main() method; in fact many do not. All Java applications how-
ever, must include a method named main(), and most Java applications have additional
methods.When you execute a Java application, the compiler always executes the main()
method first.
In the method header public static void main(String[] args), you already
might recognize that the contents between the parentheses, (String[] args), must
represent an argument passed to the main() method, just as the string “First Java pro-
gram” is an argument passed to the println() method. String represents a Java class that
can be used to represent character strings.The identifier args is used to hold any Strings
that might be sent to the main() method.The main() method could do something with
those arguments, such as print them, but in Figure 1-2 the main() method does not actu-
ally use the args identifier. Nevertheless, you must place an identifier within the main()
method’s parentheses.The identifier does not need to be named args—it could be any
legal Java identifier—but the name args is traditional.
When you refer to the String class in the main() method header, the square
brackets indicate an array of String objects. You will learn more about arrays
Tip and the String class in Chapter 6.
1 Chapter A4758 5/3/04 10:27 am Page 12
The simple program shown in Figure 1-2 has many pieces to remember. However, for
now, you can use the program shown in Figure 1-4 as a shell, where you replace the line
/******/ with any statements that you want to execute.
Now that you understand the basic framework of a program written in the Java pro-
gramming language, you are ready to enter your first Java program into a text editor. It
is a tradition among programmers that the first program you write in any language pro-
duces “Hello, world!” as its output.You will create such a program now.You can use any
text editor, such as Notepad, Textpad, or any other text-processing program.
To write your first Java program:
1. Start any text editor (such as Notepad or Textpad, but be sure the file is saved
with the extension .txt), and then open a new document, if necessary.
(Textpad is the easiest program to use to write your programs.)
2. Type the class header publicƒclassƒHello. In this example, the class
name is Hello.You can use any valid name you want for the class. If you
choose Hello, you must refer to the class as Hello, and not as hello, because
the Java programming language is case sensitive.
3. Press [Enter] once, type {, press [Enter] again, and then type }.You will add
the main() method between the curly braces. Although it is not required, it is
a good practice to place each curly brace on its own line. This makes your
code easier to read.
4. As shown in Figure 1-5, add the main() method header between the curly
braces and then type a set of curly braces for main().
Figure 1-5 The main() method shell for the Hello class
1 Chapter A4758 5/3/04 10:27 am Page 13
Next add the statement within the main() method’s brackets that will produce the out-
put, “Hello, world!”.
1
5. Use Figure 1-6 as a guide for adding a println() statement to the main() method.
Many text editors attach their own filename extension (such as .txt or .doc)
?
Help
to a saved file. Double-check your saved file to ensure that it does not have
a double extension (such as Hello.java.txt). If the file has a double extension,
rename the file. If you explicitly type quotation marks surrounding a filename
(such as “Hello.java”), most text editors will save the file as you specify, with-
out adding an extension. Make sure that you save your .java files as text
documents. The default for Notepad is to save all documents as text.
It is suggested that as you work through this book you add comments as the
first three lines of every program. The comments should contain the program
Tip name, your name, and the date. Your instructor might ask you to include
additional comments.
1 Chapter A4758 5/3/04 10:27 am Page 14
Comments also can serve a useful purpose when you are developing a program. If a
program is not performing as expected, you can comment out various statements and
subsequently run the program to observe the effect. When you comment out a state-
ment, you turn it into a comment so the compiler will not execute its command. This
helps you pinpoint the location of errant statements in malfunctioning programs.
There are three types of comments in the Java programming language:
■ Line comments start with two forward slashes (//) and continue to the end
of the current line. Line comments can appear on a line by themselves or at
the end of a line following executable code.
■ Block comments start with a forward slash and an asterisk (/*) and end
with an asterisk and a forward slash (*/). Block comments can appear on a
line by themselves, on a line before executable code, or after executable code.
Block comments also can extend across as many lines as needed.
■ A special case of block comments are javadoc comments. They begin with a
forward slash and two asterisks (/**) and end with an asterisk and a forward
slash (*/).You can use javadoc comments to generate documentation with a
program named javadoc.
The forward slash (/) and the backslash (\) characters often are confused, but
they are two distinct characters. You cannot use them interchangeably.
Tip
The Java Development Kit (JDK) includes the javadoc tool, which contains classes
that you can use when writing programs in the Java programming language.
Tip
//Demonstrating comments
/* This shows
that these comments
don't matter */
System.out.println("Hello");//This line executes
// up to where the comment started
/**Everything but the println() line
is a comment. */
When compiling, if the source code file is not in the current path, you can
type a full path with the filename, for example, javac
Tip c:\java\myprograms\First.java.
1 Chapter A4758 5/3/04 10:27 am Page 16
If you receive a message such as Bad command or filename, it might mean one of
the following:
■ You misspelled the command javac.
■ You misspelled the filename.
■ You are not within the correct subfolder or subdirectory on your command line.
■ The Java programming language was not installed properly. (See Appendix for
information on installation.)
If you receive a programming language error message, then there are one or more syn-
tax errors in the source code. A syntax error is a programming error that occurs when
you introduce typing errors into your program. For example, if your class name is “first”
(with a lowercase f) in the source code, but you saved the file as First.java, you will get
an error message, such as public class first should not be defined in
First.java, after compiling the program because “first” and “First” are not the same
in a case-sensitive language. If this error occurs, you must reopen the text file that con-
tains the source code and make the necessary corrections.
If you receive no error messages after compiling the code in a file named First.java, then
the program compiled successfully, and a file named First.class was created and saved in
the same folder as the program text file. After a successful compile, you can run the class
file on any computer that has a Java language interpreter.
To run the program from the command line, you type javaƒFirst. Figure 1-8 shows
the program’s output. Next you will compile and interpret your Hello2.java program.
If you receive an error message, look in the section “Running a Java Program”
1
?
Help
to find its cause, and then make the necessary corrections. Save the file again,
and then repeat Steps 1 and 2 until your program compiles successfully.
When you run a Java program using the java command, do not add the
.class extension to the filename. If you type javaƒFirst, the interpreter
Tip will look for a file named First.class. If you type javaƒFirst.class, the
interpreter will incorrectly look for a file named First.class.class.
The three changes are the class name change of First to First2, the addition of the statement
System.out.println("My new and improved");, and the removal of the word
“First” from the string in the statement System.out.println("Java'ƒprogram");.
However, if you type java First2 at the command line right now, you will not see the
new output—you will see the old output. Before the new source code will execute, you
must do the following:
1. Save the file with the changes using the same filename (First2.java).
2. Compile the First2 class with the javac command.
3. Interpret the First2.class bytecode with the java command.
Next you will change your Hello2 class and rerun your program.
To change the Hello2 class and rerun the program:
1. Open the file Hello2.java in your text editor. Change both the comment
name and the class name to Hello3.
2. Add the following statement below the statement that prints “Hello, world!”:
System.out.println("I'mƒreadyƒforƒJavaƒprogramming!");.
Make sure to type the semicolon at the end of the statement and use the
correct case.
3. Save the file as Hello3.java in the Chapter.01 folder on your Student Disk.
Changing the Hello2 class name to Hello3 and saving the file as Hello3 calls
attention to the change being made to the Hello2 class.
4. At the command line, compile the file by typing the command
javacƒHello3.java.
If you receive compile errors, return to the Hello3.java file in the text editor,
?
Help
fix the errors, and then repeat Steps 3 and 4 until the program compiles
successfully.
5. Interpret and execute the class by typing the command java Hello3, and
then press [Enter].Your output should look like Figure 1-11.
1 Chapter A4758 5/3/04 10:27 am Page 19
questions about Java software and products. A site search for the Java Development Kit
(JDK) will help you locate and download the latest JDK for free. At the time of this
writing the latest version is The JavaTM 2 Platform, Standard Edition v1.4.0, available in
Windows, Linux, and Solaris operating systems.You can search and browse documenta-
tion online or you can download the documentation file for the SDK and install it on
your computer. Once installed, you can search and browse documentation locally.
A downloadable Java tutorial titled “The Java Tutorial: A practical guide for pro-
grammers”, with hundreds of complete working examples is available from
http://java.sun.com/docs/books/tutorial/. The tutorial is organized into trails—groups of
lessons on a particular subject. You can start the tutorial at the beginning and navigate
sequentially from beginning to end, or jump from one trail to another.As you study each
textbook chapter you are encouraged to make good use of these support materials.
CHAPTER SUMMARY
❒ Objects are made up of states and methods. The states of an object also are known
as its attributes. An individual object is an instance of a class; the object inherits its
attributes from the class. The user of an object does not need to understand the
details of any method, but must understand the interface with the object.
❒ A program written in Java is run on a standardized hypothetical computer called
the Java virtual machine (JVM) that exists virtually inside your machine by a pro-
gram. When your program is compiled into bytecode, an interpreter within the
JVM subsequently interprets the bytecode and interfaces with the operating system
to produce the program results.
❒ All Java programming language statements end with a semicolon. Periods (called
dots) are used to separate classes, objects, and methods in program code. The con-
tents of all classes are contained within opening and closing curly braces. A series of
characters that appears between double quotation marks is a literal string. Java pro-
gramming language methods might require arguments or messages to perform the
appropriate task.
❒ Everything that you use within a Java program must be part of a class. A Java pro-
gramming language class might take any name or identifier that begins with either
an uppercase or lowercase letter of the alphabet, and contains only uppercase and
lowercase letters, digits, and underscores. A class name cannot be a reserved key-
word of the Java programming language.
❒ The reserved word public is an access modifier that defines the circumstances
under which a class can be accessed. The keyword static in a method header
indicates that every member of a class will have an identical, unchanging method.
The keyword void in a method header indicates that the method does not return
any value when it is called.
1 Chapter A4758 5/3/04 10:27 am Page 21
Review Questions 21
❒ All Java application programs must have a method named main(). Most Java applica-
tions have additional methods.
1
❒ Program comments are nonexecuting statements that you add to a program for the
purpose of documentation. There are three types of comments in the Java program-
ming language: line comments begin with two forward slashes (//); block com-
ments begin with a forward slash and an asterisk (/*) and end with an asterisk and
a forward slash (*/); and javadoc comments begin with a forward slash and two
asterisks (/**) and end with an asterisk and a forward slash (*/).
❒ To compile your source code from the command line, type javac followed by the
name of the file that contains the source code. If the file resides in a different path
from the command prompt, use the full path and filename. When you compile your
source code, the compiler creates a file with a .class extension.You can run the
.class file on any computer that has a Java language interpreter by entering the
java command followed by the name of the class file. Do not type the .class
extension with the filename.
❒ When you modify a program, before it will execute correctly, you must do the
following: save the file with the changes using the same filename, compile the
class with the javac command, and interpret the class bytecode with the java
command.
❒ To avoid and minimize syntax and logic errors you must enter code carefully and
closely examine your program’s output.
REVIEW QUESTIONS
1. The most basic circuitry-level computer language, which consists of on and off
switches, is .
a. a high-level language
b. machine language
c. the Java programming language
d. C++
2. Languages that let you use a vocabulary of descriptive terms such as “read,”
“write,” or “add” are known as languages.
a. high-level
b. machine
c. procedural
d. object-oriented
1 Chapter A4758 5/3/04 10:27 am Page 22
Review Questions 23
c. method 1
d. class
10. The Java programming language is architecturally .
a. specific
b. oriented
c. neutral
d. abstract
11. You must compile programs written in the Java programming language into
.
a. bytecode
b. source code
c. javadoc statements
d. object code
12. All Java programming language statements must end with a .
a. period
b. comma
c. semicolon
d. closing parenthesis
13. Arguments to methods always appear within .
a. parentheses
b. double quotation marks
c. single quotation marks
d. curly braces
14. In a Java program, you must use to separate classes, objects,
and methods.
a. commas
b. semicolons
c. periods
d. forward slashes
15. All Java programs must have a method named .
a. method()
b. main()
c. java()
d. Hello()
1 Chapter A4758 5/3/04 10:27 am Page 24
Exercises 25
EXERCISES 1
1. For each of the following Java programming language identifiers, note whether
they are legal or illegal:
a. weeklySales
b. last character
c. class
d. MathClass
e. myfirstinitial
f. phone#
g. abcdefghijklmnop
h. 23jordan
i. my_code
j. 90210
k. year2000problem
l. abffraternity
2. Name some attributes that might be appropriate for each of the following classes:
a. TelevisionSet
b. EmployeePaycheck
c. PatientMedicalRecord
3. Write, compile, and test a program that prints your first name on the screen. Save
the program as Name.java in the Chapter.01 folder on your Student Disk.
4. Write, compile, and test a program that prints your full name, street address, city,
state, and zip code on three separate lines on the screen. Save the program as
Address.java in the Chapter.01 folder on your Student Disk.
5. Write, compile, and test a program that displays the following pattern on the screen:
X
XXX
XXXXX
XXXXXXX
X
Save the program as Tree.java in the Chapter.01 folder on your Student Disk.
1 Chapter A4758 5/3/04 10:27 am Page 26
6. Write, compile, and test a program that prints your initials on the screen.
Compose each initial with five lines of initials, as in the following example:
J FFFFFF
J F
J FFFF
J J F
JJJJJJ F
Save the program as Initial.java in the Chapter.01 folder on your Student Disk.
7. Write, compile, and test a program that prints all the objectives listed at the
beginning of this chapter. Save the program as Objectives.java in the Chapter.01
folder on your Student Disk.
8. Write, compile, and test a program that displays the following pattern on the screen:
*
**
***
**
*
Save the program as Diamond.java in the Chapter.01 folder on your Student Disk.
9. Write, compile, and test a program that displays the following statement about
comments:
“Program comments are nonexecuting statements you add to a program for the
purpose of documentation.”
Also include the same statement in three different comments in the program; each
comment should use one of the three different methods of including comments
in a Java program. Save the program as Comments.java in the Chapter.01 folder
on your Student Disk.
10. Each of the following files in the Chapter.01 folder on your Student Disk has
syntax and/or logical errors. In each case, determine the problem and fix the pro-
gram. After you correct the errors, save each file using the same filename preceded
with Fix. For example, DebugOne1.java will become FixDebugOne1.java.
a. DebugOne1.java
b. DebugOne2.java
c. DebugOne3.java
d. DebugOne4.java
1 Chapter A4758 5/3/04 10:27 am Page 27
Case Project 27
CASE PROJECT 1
Business Cards Limited is a company that designs and prints personal business cards.They
Case
have asked you to write a simple program using Java to provide personal business card
Project
information for a typical order.The format to be displayed is shown in the table below:
Write, compile, and test a Java program to print the table layout using your own per-
sonal information. Be sure to use good documentation principles for your program. Save
the program as CardLayout in the Chapter.01 folder on your Student Disk.
1 Chapter A4758 5/3/04 10:27 am Page 28