Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVA

java define a generic class that produces


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

for(Object obj : list){
	//type casting leading to ClassCastException at runtime
    String str=(String) obj; 
}
Source by www.journaldev.com #
 
PREVIOUS NEXT
Tagged: #java #define #generic #class #produces
ADD COMMENT
Topic
Name
8+5 =