Quick Refresh : Java 1.5 : Generics
Why Use Generics? In a nutshell, generics enable types (classes and interfaces) to be parameters when defining classes, interfaces and methods. Much like the more familiar formal parameters used in method declarations, type parameters provide a way for you to re-use the same code with different inputs. The difference is that the inputs to formal parameters are values, while the inputs to type parameters are types. It was introduced in java 1.5. Benefits of Code that uses generics over non-generic code: Type-safety: We can hold only a single type of objects in generics. It doesn't allow to store other objects. Without Generics, we can store any type of objects. List list = new ArrayList(); list.add( 10 ); list.add( "10" ); With Generics, it is required to specify the type of object we need to store. List...