Check out example codes for "java define a generic class that produces". It will help you in understanding the concepts better.

Code Example 1

List<String> list1 = new ArrayList<String>(); // java 7 ? List<String> list1 = new ArrayList<>(); 
//list1.add(new Integer(5)); //compiler error

for(String str : list1){
     //no type casting needed, avoids ClassCastException

Code Example 2

List list = new ArrayList();
list.add(new Integer(5)); //OK

for(Object obj : list){
	//type casting leading to ClassCastException at runtime
    String str=(String) obj; 

Learn ReactJs, React Native from