Java Reference
In-Depth Information
containing all the ideas and source code discussed here, as well as several intermediate versions,
is included in the topic projects. While this enables you to study the complete solution, you are
encouraged to follow the path through the exercises in this chapter. These will, after a brief look
at the complete program, start with a very simple initial version of the project and then gradually
develop and implement the complete solution.
The application makes use of several new library classes and techniques—each requiring study
individually—such as hash maps, sets, string tokenization, and further use of random numbers.
You should be aware that this is not a chapter to be read and understood in a single day, but that
it contains several sections that deserve a few days of study each. Overall, when you finally
reach the end and have managed to undertake the implementation suggested in the exercises,
you will have learned about a good variety of important topics.
5.1
Documentation for library classes
The Java library is big. It consists of thousands of classes, each of which has many methods, both
with and without parameters, and with and without return types. It is impossible to memorize
them all and all of the details that go with them. Instead, a good Java programmer should know:
Concept:
Java library. The
Java standard
class library
contains many
classes that are
very useful. It is
important to know
how to use the
library.
some of the most important classes and their methods from the library by name ( ArrayList
is one of those important ones) and
how to find out about other classes and look up the details (such as methods and parameters).
In this chapter, we will introduce some of the important classes from the class library, and
further library classes will be introduced throughout the topic. But, more importantly, we will
show you how you can explore and understand the library on your own. This will enable you to
write much more interesting programs. Fortunately, the Java library is quite well documented.
This documentation is available in HTML format (so that it can be read in a web browser). This
is what we shall use to find out about the library classes.
Reading and understanding the documentation is the first part of our introduction to library
classes. We will take this approach a step further and also discuss how to prepare our own
classes so that other people can use them in the same way as they would use standard library
classes. This is important for real-world software development, where teams have to deal with
large projects and maintenance of software over time.
One thing you may have noted about the ArrayList class is that we used it without ever look-
ing at the source code.We did not check how it was implemented. That was not necessary for
utilizing its functionality. All we needed to know was the name of the class, the names of the
methods, the parameters and return types of those methods, and what exactly these methods
do. We did not really care how the work was done. This is typical for the use of library classes.
The same is also true for other classes in larger software projects. Typically, several people
work together on a project by working on different parts. Each programmer should concentrate
on her own area and need not understand the details of all the other parts (we discussed this in
Section 3.2 where we talked about abstraction and modularization). In effect, each programmer
should be able to use the classes of other team members as if they were library classes, making
informed use of them without the need to know how they work internally.
 
 
Search WWH ::




Custom Search