SHARE
TWEET

総称型の抜け穴

EnderAlice Mar 31st, 2015 244 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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. }
RAW Paste Data
Top