[問題] 泛型詢問
例如在下列程式碼中
class MyClass<E>
{
public <T> MyClass(T t)
{
System.out.println("t is " + t.getClass());
}
}
public class GenericDiamondTest
{
public static void main(String[] args)
{
MyClass<String> mc1 = new MyClass<>(5);
MyClass<String> mc2 = new <Integer> MyClass<String>(5);
//MyClass<String> mc3 = new <Integer> MyClass<>(5);
}
}
當我建立一個泛型方法並只叫用這方法時
parameterized type是不是變得並不重要?
然後在使用型別強制轉換時 java是不是規定不能使用diamond operator的寫法
而且parameterized type也一樣變得不重要?
請各位前輩多指導 感謝
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 36.224.193.231
※ 文章網址: https://www.ptt.cc/bbs/java/M.1489144505.A.B0E.html
→
03/10 19:40, , 1F
03/10 19:40, 1F
→
03/10 19:40, , 2F
03/10 19:40, 2F
→
03/11 07:23, , 3F
03/11 07:23, 3F
→
03/11 07:24, , 4F
03/11 07:24, 4F
java 近期熱門文章
PTT數位生活區 即時熱門文章