samedi 26 décembre 2015

Find Generic Type at Runtime Java

I wrote some code the looks like this:

public class A<T> {
    public Type getGenericType() {
        // should return the type of T at runtime
    }
}

meaning, the call:

A<Integer> a = new A<>();
a.getGeneicType();

should return Integer.

Is it possible in Java?





Aucun commentaire:

Enregistrer un commentaire