February 2014
Beginner
1248 pages
62h 25m
English
When the compiler translates method maximum into bytecodes, it uses erasure to replace the type parameters with actual types. In Fig. 20.3, all generic types were replaced with type Object. Actually, all type parameters are replaced with the upper bound of the type parameter, which is specified in the type-parameter section. Figure 20.6 simulates the erasure of method maximum’s types by showing the method’s source code after the type-parameter section is removed and type parameter T is replaced with the upper bound, Comparable, throughout the method declaration. The erasure of Comparable<T> is simply Comparable.
Read now
Unlock full access