The Compiler

General Compiler issues

There are no forward declarations of classes/methods necessary in Java. The compiler takes care of all definitions of methods and does not throw an error until it is sure that the method or class has not been defined elsewhere.

Libraries

The standard Java libraries are supplied by SUN and are comprehensive. In C++, the programmer uses third party code libraries that do not integrate very well with each vendor. Java provides comprehensive standard libraries from application development to networking and database access providing us with a fully integrated development language.

Exceptions

Exception handling allows run-time errors to be handled directly by the programmer. An exception object is thrown from the line of code where the error occurred and is caught by a suitable exception handler, specially designed for that type of error. Exceptions are in effect control statements that allow a different path of execution when errors occur to the normal path when no errors occur. In the Java and C++ languages exceptions cannot be ignored by the programmer, rather they must deal with them, leading to more robust applications. Exceptions exist outside of object-oriented languages, but in object-oriented languages an object is used to describe the exception.

While we did not cover exceptions in C++, they are available. However, exception specifications in Java are vastly superior to those in C++. Instead of the C++ approach of calling a function at run-time when an exception is thrown, Java exception specifications are checked and enforced at compile-time. In addition, Java over-ridden methods must conform to the exception specification of the base-class version of that method: they can throw the specified exceptions or exceptions derived from those. This provides much more robust exception-handling code.

Default Arguments

There is no support for default arguments in Java.

No Preprocessor

There are no compiler directives, no #define, no #includes

Multithreading

Java has support built into the language for multi-threading, C++ does not.

I will add more to this document as issues arise. If you notice any errors or omissions in the document then please drop me an e-mail.