13.07.2015 Views

Java™ Application Development on Linux - Dator

Java™ Application Development on Linux - Dator

Java™ Application Development on Linux - Dator

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

3.8 Review95straight Java facts so we can let the n<strong>on</strong>-C++ folks move <strong>on</strong> while we go a littledeeper with you C++’ers.In Java, a method or a class may be declared final. A method that is declaredfinal may not be overridden in classes that extend the class c<strong>on</strong>tainingthe final implementati<strong>on</strong>. A class that is declared final may not be extendedat all.Now, the comparis<strong>on</strong>s to C++ require us to talk about a language featurethat 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 usingEmployee as a Pers<strong>on</strong>), the base class versi<strong>on</strong> of the method is called. If themethod is declared virtual, the versi<strong>on</strong> of the method called is the versi<strong>on</strong> forthe type of Pers<strong>on</strong> referenced (in this case, Employee). In Java, all methodsare virtual. There is no such keyword in Java.3.7A USEFUL SIMPLE APPLICATIONWe will use the sample applicati<strong>on</strong> shown in Example 3.30 in other secti<strong>on</strong>sof this book to illustrate the use of Java tools. This example is so simple (a singleclass) that it doesn’t dem<strong>on</strong>strate the object-oriented aspect of development,but it does make use of some APIs that take advantage of it. We will not walkyou through this applicati<strong>on</strong> right here, but present it as a listing of a completeJava class. Not all of the APIs used in this example will be explained, so youmay want to refer to the Javadoc pages for explanati<strong>on</strong>s of object types ormethod calls that d<strong>on</strong>’t seem obvious.3.8REVIEWWe’ve taken a very quick look at the syntax of Java statements, classes, andinterfaces. Much of the syntax is very reminiscent of C, though Java’s objectorientedfeatures differ in significant ways from C++. We looked at how to putJava classes into packages, and at the implicati<strong>on</strong>s of this for locating the.class files.We also showed what the HTML-based Javadoc documentati<strong>on</strong> lookslike. These HTML pages will likely be a handy reference for you as you designand write your Java code.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!