Type Constraints:
Importjava.util.List;Importjava.util.ArrayList;Importjava.util.LinkedList;/*** Created by Administrator on 2016/12/30 0030.*/ public classListgenericfoo<textendsList>{ Privatet[] fooarray; publict[] getfooarray () {returnfooarray; } public voidSetfooarray (t[] Fooarray) { this. Fooarray =fooarray; } public Static voidmain (string[] Args) {listgenericfoo<LinkedList> foo1 =NewListgenericfoo<linkedlist>(); Listgenericfoo<ArrayList> Foo2 =NewListgenericfoo<arraylist>(); linkedlist[] linkedlists=NewLinkedlist[10]; Foo1.setfooarray (linkedlists); arraylist[] arraylists=NewArraylist[10]; Foo2.setfooarray (arraylists); }}
Inherit interfaces or classes, all with the extends keyword
Restriction type
extends List> list=null; List=new arraylist<linkedlist>(); List=new arraylist<arraylist> ();
Generics in ArrayList must inherit the list (of course, the list here is an interface, not possible, but a type Can) or a subclass of the list
Super Arraylist> list=null; List=new arraylist<object>(); List=new arraylist<arraylist> ();
With the super keyword, generics must be the inherited Type's own or its parent class.
Http://www.cnblogs.com/mengdd/archive/2013/01/21/2869861.html
Java generic constraints