Java generics wildcard entry -


in java generics, why not valid:

list<?> l = new arraylist()<?>; 

considering valid:

public interface somelist<?>{} 

there both unbounded wildcards. in mind both equivalent to:

list l = new arraylist(); 

and

public interface somelist {} 

where going wrong?

list<?> means one type. programmer benefit typechecking designers desided need supply one type during instantiation.

if want full flexibility, list<?> l = new arraylist<object>() way go.

the wildcard ? means of saying, yes want generics don't care of type. unlike generic-less variant, still type checking , compiler warnings necessary.


Comments

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -