Java Reference
In-Depth Information
LEARNING JAVA
Java is not difficult to learn, but there is a great deal to it. Although the Java language is very powerful, it
is fairly compact, so acquiring an understanding of the Java language should take less time than you think.
However, there's much more to Java than just the language. To be able to program effectively in Java, you
need to understand the libraries that go with the language, and these are very extensive. It is also important
to become familiar with open source projects, especially those developed by the Apache folks.
In this topic, the sequence in which you learn how the language works and how you apply it has been
carefully structured so that you gain expertise and confidence with programming in Java through a relatively
easy and painless process. As far as possible, each chapter avoids the use of things that you haven't learned
about already. A consequence, though, is that you won't be writing Java applications with application win-
dows and a Graphical User Interface (GUI) right away. Although it may be an appealing idea, this would be
a bit like learning to swim by jumping in the pool at the deep end. Generally speaking, there is good evid-
ence that by starting in the shallow end of the pool and learning how to float before you try to swim, you
minimize the chance of drowning, and there is a high expectation that you can end up being a competent
swimmer.
Java Programs
As I have already noted, there are two basic kinds of programs you can write in Java. Programs that are to
be embedded in a web page are called Java applets, and normal standalone programs are called Java applic-
ations. You can further subdivide Java applications into console applications, which only support character
output to your computer screen (console output typically goes to the command line on a PC under Microsoft
Windows, for example), and windowed applications, which can create and manage multiple windows. The
latter use the typical GUI mechanisms of window-based programs — menus, toolbars, dialogs, and so on.
While you are learning the Java language basics, you use console applications as examples to understand
how things work. These are applications that use simple command-line input and output. With this approach
you can concentrate on understanding the specifics of the language without worrying about any of the com-
plexity involved in creating and managing windows. After you are comfortable with using all the features
of the Java language, you move on to window-based applications and applet examples.
Learning Java — the Road Ahead
Before starting out on any journey, it is always helpful to have an idea of where you're heading and what
route you should take, so let's take a look at a brief road map of where you're going with Java. There are
seven broad stages you progress through in learning Java using this topic:
1. The first stage is this chapter. It sets out some fundamental ideas about the structure of Java programs
and how they work. This includes such things as what object-oriented programming is all about and
how an executable program is created from a Java source file. Getting these concepts straight at the
outset makes learning to write Java programs that much easier for you.
2. Next, in Chapters 2 to 4, I explain how statements are put together, what facilities you have for stor-
ing basic data in a program, how you perform calculations, and how you make decisions based on the
results of them. These are the nuts and bolts you need for the next stages.
3. In the third stage, in Chapters 5 and 6, you learn about classes — how you define them and how you
can use them. Classes are blueprints for objects, so this is where you learn the object-oriented charac-
Search WWH ::




Custom Search