java generics use cases 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<String> list = new ArrayList<String>();
list.add("hello");
String s = list.get(0); // no cast