Java Reference
In-Depth Information
histograms with the same number of bins, you could use a 2D array with the first
index indicating the histogram and the second index corresponding to the bins.
Similarly, you could use arrays to hold the parameters of the histograms,
such as the number of bins, the lower and upper ranges, and so forth. Functions
to add entries to the histograms would require a lot of bookkeeping to deter-
mine which histogram was needed. With objects, we just create 20 instances of
the BasicHist type and each instance knows which histogram it is, and you
don't have to worry about keeping track of the histogramming details in your
code.
Furthermore, if you wanted to use the histogram code in another program,
or let someone else use your histograms, it would be messy to extract just that
code from the program and move it into the new one. The encapsulation aspect
inherent to the object approach makes reusability far easier than with procedural
code.
3.11 Web Course materials
The Chapter 3 Web Course: Supplements section provides additional introduc-
tory material about class definitions and objects. It also lists differences between
object-oriented programming in Java and C
, and reviews memory manage-
ment in Java (Garbage Collection) and the internals of the JVM.
The Chapter 3: Te ch section looks further at OOP in science and engineering
applications. It also provides complex number and histogram codes and demon-
stration programs. The Chapter 3: Physics section gives a tutorial on OOP in
physics and continues with more examples of numerical computing techniques
with Java.
++
Resources
Didier H. Besset, Object-Oriented Implementation of Numerical Methods: An Introduction
with Java and Smalltalk , Morgan Kaufmann, 2001.
Cay S. Horstmann and Gary Cornell, Core Java 2: Vol. 1 - Fundamentals , 6th edn, Sun
Microsystems, 2002.
Patrick Niemeyer and Joshua Peck, Learning Java , 2nd edn, O'Reilly, 2002.
Monica Pawlan, Essentials of the Java Programming Language: A Hands-on Guide , March
1999, http://developer.java.sun.com/developer/onlineTraining/
Programming/BasicJava1/ .
The Java Tutorial , Sun Microsystems,
http://java.sun.com/docs/books/tutorial/ .
Search WWH ::




Custom Search