Java Reference
In-Depth Information
straight Java facts so we can let the non-C++ folks move on while we go a little
deeper with you C++'ers.
In Java, a method or a class may be declared final . A method that is de-
clared final may not be overridden in classes that extend the class containing
the final implementation. A class that is declared final may not be extended
at all.
Now, the comparisons to C++ require us to talk about a language feature
that does not exist at all in Java. In C++, unless a method is declared virtual ,
when a class is used by reference to a base class (for example, when using
Employee as a Person ), the base class version of the method is called. If the
method is declared virtual, the version of the method called is the version for
the type of Person referenced (in this case, Employee ). In Java, all methods
are virtual. There is no such keyword in Java.
3.7
A U SEFUL S IMPLE A PPLICATION
We will use the sample application shown in Example 3.30 in other sections
of this topic to illustrate the use of Java tools. This example is so simple (a single
class) that it doesn't demonstrate the object-oriented aspect of development,
but it does make use of some APIs that take advantage of it. We will not walk
you through this application right here, but present it as a listing of a complete
Java class. Not all of the APIs used in this example will be explained, so you
may want to refer to the Javadoc pages for explanations of object types or
method calls that don't seem obvious.
3.8
R EVIEW
We've taken a very quick look at the syntax of Java statements, classes, and
interfaces. Much of the syntax is very reminiscent of C, though Java's object-
oriented features differ in significant ways from C++. We looked at how to put
Java classes into packages, and at the implications of this for locating the
.class files.
We also showed what the HTML-based Javadoc documentation looks
like. These HTML pages will likely be a handy reference for you as you design
and write your Java code.
Search WWH ::




Custom Search