Posts

Java Generics - 4. Generic Methods

Image
This is part 4 of the 9 part series on Java Generics  Prev Topic Multiple bounding 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 Wildcards Java Generics - Generic Methods Can you write generic methods on the same lines? Yes you can. The same rules that applied earlier applies here too. Let us have a look at the class called GenericMethods .   public class GenericMethods {               public <E> void print(E e ){               System. out .println( "e=" + e );        }               public static void ...