I have a class with various variables
public class myClass{
public int id;
public String category;
public String description;
public String star
You can do it using reflection, though I would recommend to check if it is really needed or maybe there's another way to do it.
For example:
Class> clz = MyClass.class;
try {
Field f = clz.getField("foo")
}
catch ( NoSuchFieldException ex) {
// field doesn't exist
}
catch (SecurityException ex) {
// no access to field
}