I have the following bean class:
public class A{
private String field;
public String getField() {
return field;
}
private String setField(String field) {
this.field = field;
}
}
And the following class:
public class B{
public static void main(String[] args){
A a = new A();
//do stuff
String f = //get a's field value
}
}
How can I get the value returned by the getter of a particular object of class A
? Of course, I can invoke method with Method.invoke(Object obj, Object... args)
but I wouldn't like to write "get"
prefix manually. Is it possible to avoid that?