java - Generics with same base class -


i have treenode class defined so:

class treenode<t extends myclass> {     public t element;     public treenode<? extends myclass> parent;     public arraylist<treenode<? extends myclass>> children; } 

i know if there easier way restrict treenodes generic type variables extend myclass? having write out arraylist<treenode<? extends myclass>> tedious. can't arraylist<treenode<t>> because tree cannot contain nodes different inheritance of myclass.

i tried this: public static const class node_class = treenode<? extends treenode>.class; don't think can use generics part of class object.

someting synonymous c++'s typedef guess, i.e. typedef treenode<? extends myclass> nodeclass;

since comment seemed you, i'll post answer:

i don't see point of using generics if t doesn't match between nodes in tree. given that, element should myclass.


Comments

Popular posts from this blog

how to insert data php javascript mysql with multiple array session 2 -

multithreading - Exception in Application constructor -

windows - CertCreateCertificateContext returns CRYPT_E_ASN1_BADTAG / 8009310b -