Java Reference
In-Depth Information
Java is similar to C++
ThebasicsyntaxofJavaisidenticaltoC++.However,thedesignersofJava
proposed to solve several problems that had plagued C++ and to eliminate
features that were considered non-essential. The most visible difference is
thatJavaisapureobject-orientedlanguage.ThismeansthatJavaprograms
must always use OO structures, while in C++ object-orientation can be
turnedoff.ThefollowingaresomeimportantdifferencesbetweenJavaand
C++.Donotworryifyoucannotunderstandalltheterminologyatthistime
since all of this is revisited later.
InJava,thesizeofthedatatypesisthesameforallplatforms.Forexample,a
Java int data type must be encoded as a 32-bit signed 2s complement repre-
sentation(moreonthislater)ineveryplatformtowhichJavaisported.This
is not the case in other languages in which the size of the data types can
change from one system to another one. This feature of Java is necessary to
ensure portability.
In contrast with C and C++, Java performs automatic garbage collection at
run time. It is the language, not the programmer, who takes care of reclaim-
ing storage that is no longer in use. This simplifies the coding and program
design.
Javasupportsmultithreading.A thread canbelooselydefinedasanindivid-
ual program task. Multithreading allows an application to perform several
tasks simultaneously. By supporting thread synchronization and schedul-
ing, as well as the handling of deadlocks, Java makes it possible to develop
codethatmakesbetteruseofsystemresourcesandenhancesperformance.
Java allows the programmer to deal with error conditions by means of ex-
ceptions. This simplifies the code and reduces clutter by offloading the er-
ror processing operations.
Java is a smaller and simpler language than C and C++. It is easier to learn
and use and is more reliable.
Java is free. All of the Java compilers, runtime, and standard libraries are
provided by Sun Microsystems at no charge. The software can be down-
loaded from the Sun Websites and there are no royalties to be paid for its
use. The programs that you build using Java software can be sold without
displaying acknowledgments, disclaimers, or other statements of accep-
tance or recognition.
Java uses libraries
The Java language is quite small. Much of the language's functionality is
achieved through libraries. There are two types of Java libraries: the core
libraries that are part of the Java Development Kit (JDK), and the optional
Search WWH ::




Custom Search