KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I have been using a little generic method to create sets from vararg of elements, eg public <T> Set<T> createSet( T... elements ) { ... Recently, however, I came across a situation where the compiler did not do what I expected it to do. Of the following createSet() uses only s3 works. Set<Class<? extends Throwable>> s1 = createSet( Exception.class, RuntimeException.class ); Set<? extends Class<Throwable>> s2 = createSet( Exception.class, RuntimeException.class ); Set<? extends Class<? extends Throwable>> s3 = createSet( Exception.class, RuntimeException.class ); Can anyone give a clear explanation of why s3 works and what might be wrong with my thinking regards s1 -- which was my initial coding? Thanks.
Tags (comma-separated)
Save Edits
Cancel