Java Generics - 7. Upper and Lower Bounds
This is part 7 of the 9 part series on Java Generics Prev Topic Typed Classes as method parameters Topics 1. Introduction 2. Bounding 3. Multiple bounding 4. Generic Methods 5. Wildcards 6. Typed Classes as method parameters 7. Upper and Lower Bounds 8. Target Types 9. Type Erasure Next Topic Target Types Java Generics - Upper and Lower Bounds This is going to be a really long blog, so please bear with me. Declaring Generic Variables You can also use generics to declare the variables. In other work you can choose which types can be assigned to a variable. The rules are more or less the same as for methods. You cannot define a type variable, like you could for the methods. Thus the declaration below makes no sense. // invalid private <E extends Fruit> E var1 = null ; ...
Comments
Post a Comment