Java Generics & Nested Classes
Mini-Exercises
Code examples
You can download and run these if you want:
Additional Code examples
- Ambig.java -
shows potential for ambiguity in selecting an overloaded method
- Widest.java - generic method example
- Wild2a.java - like Wild2, but uses a type
parameter rather than a wildcard. (The Sun Java tutorial says this isn't
as good style as using a wildcard - it's included here for comparison sake.)
- Wild3a.java - like Wild3, but uses a
bounded type parameter rather than a wildcard. (Again Sun recommends
using a wildcard in this case though.)
- Wild4.java - example of casting a generic of
unknown (wildcard) type to a known type
References