jeudi 20 avril 2017

Passing Child.class as argument

I have a method that should receives a Class<A>, something like:

protected void method(final Class<A> clazz) {
}

Then when I try to call like method(A.class) it do works, but if I try method(B.class), where B is child of A, I get the message "incompatible types".

The solution is change to Class<B>, but I have another childs that I like to pass as argument to this method(), like C.class.






Comments
0 Comments

0 commentaires:

Enregistrer un commentaire