class Foo{
private int lorem; //
private int ipsum;
public setAttribute(String attr,int val){
//sets attribute based on name
}
public static void main(String [] args){
Foo f = new Foo();
f.setAttribute("lorem",1);
f.setAttribute("ipsum",2);
}
public Foo(){}
}
public void setIntField(String fieldName,int value)
throws NoSuchFieldException,IllegalAccessException {
Field field = getClass().getDeclaredField(fieldName);
field.setInt(this,value);
}