samedi 10 juin 2017

Java reflection getTypeParameters().length returns 0

I have a simple class

public class Pet {
    private String petName;
    private int petAge;

    public Pet() {
    }

    public Pet(String petName, int petAge) {
        this.petName = petName;
        this.petAge = petAge;
    }
}

When I'm trying to find arguments, I get two zeros. I still can't find out why. Any suggestion?

        Constructor[] constructors = Pet.class.getDeclaredConstructors();
        for (Constructor c : constructors) {
            System.out.println(c.getTypeParameters().length);
        }





Aucun commentaire:

Enregistrer un commentaire