when to use generics in java code example
Example 1: why use generic in real life
List list = new ArrayList();
list.add("hello");
String s = (String) list.get(0);
Example 2: why use generic in real life
List list = new ArrayList();
list.add("hello");
String s = list.get(0); // no cast