Java中泛型中擦除的概念是什么?Java中泛型中擦除的概念是什么?
3 回答
FFIVE
TA贡献1797条经验 获得超6个赞
import java.util.ArrayList;import java.util.Iterator;import java.util.List;public class GenericsErasure { public static void main(String args[]) { List<String> list = new ArrayList<String>(); list.add("Hello"); Iterator<String> iter = list.iterator(); while(iter.hasNext()) { String s = iter.next(); System.out.println(s); } }}
import java.io.PrintStream;import java.util.*;public class GenericsErasure{ public GenericsErasure() { } public static void main(String args[]) { List list = new ArrayList(); list.add("Hello"); String s; for(Iterator iter = list.iterator(); iter.hasNext(); System.out.println(s)) s = (String)iter.next(); }}
添加回答
举报
0/150
提交
取消