MyList<T>{ private T[] elements; public boolean add(T elem){} public T get(int idx){} } class MyList{ private String[] elements; public boolean add(String elem){} public String get(int idx){} } MyList<String>と宣言すると そのインスタンスは 右になるイメージ(厳密には違う) class MyMap<K,V>{ private V put(K key,V value); } 9
public interface Storable{ Long getId(); } public class User implements Storable{ ... } public void showId(List<Storable> list){ for(Storable storable : list){ System.out.println(storable.getId()); } } List<User> userList = new ArrayList<User>(); showId(userList); //コンパイルエラー 22