GenMap在聲明是使用了
清單
GenMap gm = new GenMap();
GenMap gm
上例中
清單
public class GenMap {
//編譯錯誤
public void set(T t){}
public void set(V v){}
}
在上面這段代碼
清單
public class GenMap {
public void setKey(T t){}
public void setValue(V v){}
}
前面我們創建了范型的列表
public static void print(GenList list){} //編譯錯誤
在這種情況下
public static void print(GenList list){}
public static void print(GenList list){}
…
public static void print(GenList list){}
J
public static void print(GenList list) {}
(
T t= new T(); //編譯錯誤
(
T[] ts= new T[
(
public class GenClass {
private static T t; //編譯錯誤
}
(
public GenExpection extends Exception{} //編譯錯誤
范型是J
From:http://tw.wingwit.com/Article/program/Java/ky/201311/28132.html