mardi 12 mai 2015

How can I get Enum fields using reflection in Java?

This is my class:

public enum Currency {
NIS, USD, EUR, GBP, JPY, AUD, CAD, DKK, NOK, ZAR, SEK, CHF, JOD, LBP, EGP;

private String name;
private int unit;
private String country;
private double rate;
private double change;

}

Since java se8 you can declare methods and more fields. when I tried to get the fields of this class using reflection I got the private fields and the enum constants (NIS,EUR,....)

How can I get only the private fields?





Aucun commentaire:

Enregistrer un commentaire