September 2011
Beginner
650 pages
15h 47m
English
A constructor can be generic, even if its class is not. For example, in the following program, the class Summation is not generic, but its constructor is.

The Summation class computes and encapsulates the summation of the numeric value passed to its constructor. Recall that the summation of N is the sum of all the whole numbers between 0 and N. Because Summation( ) specifies a type parameter that is bounded by Number, a Summation object can be constructed using any numeric type, including Integer, Float, or Double. No matter what numeric type is used, its value is converted to Integer by calling intValue( ), and the summation ...
Read now
Unlock full access