Java Reference
In-Depth Information
double wtTotal = 0;
double wtTotal2 = 0;
double [] stat = new double[2];
double binWidth = range/numBins;
for (int i = 0; i < numBins; i++) {
total + = bins[i];
double binMid = (i - 0.5) * binWidth + lo;
wtTotal + = bins[i] * binMid;
wtTotal2 + = bins[i] * binMid * binMid;
}
if (total > 0) {
stat[0] = wtTotal/total;
double av2 = wtTotal2/total;
stat[1] = Math.sqrt (av2 - stat[0]*stat[0]);
}
else {
stat[0] = 0.0;
stat[1] = -1.0;
}
return stat;
} // getStats
} // class BetterHist
4.11 Understanding OOP
Chapters 3 and 4 present the fundamentals of class definitions and objects. In
Chapter 5 we look at how classes are organized into files and directories and how
the JVM locates classes. If you find that object-oriented programming (OOP)
remains somewhat vague, your understanding of the concepts involved will
deepen as you see OOP techniques applied to graphics, threading, I/O, and other
areas in subsequent chapters. We return to class structure, design, and analysis
in Chapter 16 where we give a brief overview of the Unified Modeling Language
(UML). UML provides a systematic approach to the design of classes and to
analysis of the interactions among objects. We then use UML to design a set of
classes for a distributed computing example.
4.12 Web Course materials
The Web Course Chapter 4: Supplements section provides more discussion of
inheritance and the overriding and overloading features. There is also discussion
of security aspects of Java including the checking of code by the JVM during
class loading. It also gives a brief overview of the security manager.
 
Search WWH ::




Custom Search