I have a class with various variables
public class myClass{ public int id; public String category; public String description; public String star
Your compiler usually knows that pretty well, and the runtime lets you examine loaded classes with reflection.
Object someObject = ... Class> someClass = someObject.getClass(); Field someField = someClass.getField("foo");
The getField() method will throw an exception if the field can not be found.