List<? extends T> upperList=new ArrayList();;
List<? super T> floorList=new ArrayList();
//合法
(T)upperList.get(index)
//不合法
upperList.set(new T())
//不合法
(T)floorList.get(index)
//合法
floorList.set(new T());
关于通配符上限下限
最新推荐文章于 2022-03-20 19:38:04 发布