Java Reference
In-Depth Information
In this chapter, you will learn the basics of Java. As you begin to learn the Java
programming language, two questions naturally arise: First, what is a computer program?
Second, what is programming? A computer program, or a program, is a sequence of
statements intended to accomplish a task. Programming is a process of planning and
creating a program. These two definitions tell the truth, but not the whole truth, about
programming. It might take an entire book to give a satisfactory definition of program-
ming. An analogy might help you gain a better grasp of the nature of programming, so
we'll use a topic on which almost everyone has some knowledge—cooking. A recipe is
also a program, and everyone with some cooking experience can agree on the following:
1. It is usually easier to follow a recipe than to create one.
2. There are good recipes and there are bad recipes.
3. Some recipes are easy to follow and some are difficult to follow.
4. Some recipes produce reliable results and some do not.
5. You must have some knowledge of how to use cooking tools to follow a
recipe to completion.
6. To create good new recipes, you must have significant knowledge and
understanding of cooking.
These same six points can also be applied to programming. Let us take the cooking analogy
one step further. Suppose you want to teach someone how to become a chef. How would
you go about it?Would you introduce the person to good food, hoping the person develops
a taste for it? Would you have the person follow recipe after recipe in the hope that some of
the techniques rub off? Or, would you first teach the use of the tools, the nature of
ingredients and foods and spices, and then explain how these concepts fit together?
Just as there are many ways to teach cooking, there are also different ways to teach
programming. However, some fundamentals apply to programming, just as they do to
cooking or other activities, such as music.
Learning a programming language is like learning to become a chef or learning to play a
musical instrument. All three skills require direct interaction with the tools. You cannot
become a good chef just by reading recipes. Similarly, you cannot learn to play musical
instruments by reading topics about musical instruments. The same is true of programming.
You must have a fundamental knowledge of the language, and you must test your programs
on the computer to make sure that each program does what it is supposed to do.
A Java Program
In this and the next chapter, you will learn the basic elements and concepts of the Java
programming language used to create a Java program. In addition to giving examples to
illustrate various concepts, we also include Java programs to help clarify the concepts.
This section gives an example of a Java program. At this point you need not be too
 
 
Search WWH ::




Custom Search