Advertisement
EnderAlice

総称型の抜け穴

Mar 31st, 2015
334
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.28 KB | None | 0 0
  1. import java.util.*;
  2.  
  3. class GenericTest
  4. {
  5.     public static void main(String[] argv)
  6.     {
  7.         List<Exception> a = new ArrayList<Exception>();
  8.         List<? extends Exception> b = a;
  9.         List c = b;
  10.         c.add(new Throwable());
  11.         for(Exception d : a) System.out.println(d.toString());
  12.     }
  13. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement