Generic Type(java)
List list = new ArrayList(); list.add("something"); list.add(100);
for (int i = 0; i < list.size(); i++) { String name = (String) list.get(i); //取出Integer时,运行时出现异常 System.out.println("name:" + name); }
List<String>[] lsa = new List<String>[10]; // Not really allowed. Object o = lsa; Object[] oa = (Object[]) o; List<Integer> li = new ArrayList<Integer>(); li.add(new Integer(3)); oa[1] = li; // Unsound, but passes run time store check String s = lsa[1].get(0); // Run-time error: ClassCastException
- ListIterator Iterator
http://blog.csdn.net/longshengguoji/article/details/41551491
From satrys,
Kristen wang