I\'d like to implement a function with both generics and varargs.
public class Question {
public static void doNastyThingsToClasses(Class
The second argument Class extends A>
... that must extend the class that the first argument is (ex. argument one is a Question
so the second argument be something that extends Question
.
The Breakdown:
NastyThingsToClasses(Object.class, Question.class, SomeQuestion.class); // OK
Everything extends Object
so the second argument is correct.
NastyThingsToClasses(Question.class, SomeQuestion.class); // OK
SomeQuestion
extends Question
so thats fair game.
NastyThingsToClasses(Question.class, Object.class, SomeQuestion.class);
Object
does not extend Question
hence error.
hopefully that cleared things up.
-Brett