Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVA

java define a generic class that produces


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

for(String str : list1){
     //no type casting needed, avoids ClassCastException
}
Source by www.journaldev.com #
 
PREVIOUS NEXT
Tagged: #java #define #generic #class #produces
ADD COMMENT
Topic
Name
6+6 =