下边界
package com.test.generic;import java.util.Collection;public class TestGenericClass {public static <E> void move(Collection<E> from,Collection<? super E> to){for(E e:from){to.add(e);}}public static <K,V> void put(K key,V value){}}
通配符
package com.test.generic;import java.awt.event.ItemEvent;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.Set;import org.eclipse.jdt.internal.compiler.ast.ThisReference;import com.sun.org.apache.xerces.internal.util.NamespaceContextWrapper;public class TestGeneric {public static void main(String[] args){Box<?> box2=new Box<String>("hello");box2=new Box<Integer>(12);}}