dimanche 10 septembre 2017

Need to pass class at runtime generics scala

I think header of question is not clear but I try to explain here.

Lets say I have class A which takes a generic type T

class A[T] {
    // Doing some thing with T
}

Now I am instantiating its object but in place of T I will pass a class at runtime like

Class.forName("com.somthing.SomeClass")
new A[com.somthing.SomeClass]() //but I don't have com.somthing.SomeClass at compile time

But how can I use above class?





Aucun commentaire:

Enregistrer un commentaire