I have a class and i want to find all of it's public variables (not functions). how can i do so?
Field fields = YourClassName.class.getFields();
returns an array of all public variables of the class.
getFields() return the fields in the whole class-heirarcy. If you want to have the fields defined only in the class in question, and not its superclasses, use
getDeclaredFields(), and filter the
public ones with the following
YourClassName.class literal actually represents an object of type
java.lang.Class. Check its docs for more interesting reflection methods.