I am not allowed to alter class A, but i need to get the value of 'a'(set in the constructor). Can anyone tell me how to do that? Every other solution seems to propose a getter in class A. I am not allowed to make changes to class A in any way, no changing to public etc. The magic has to happen in class B.
public class A{
private int a;
public A(int x){
a = x * 10;
}
}
public class B{
public B(int x){
A instA = new A(x);
}
public int geta(){
???
}
}
PS: Posted this question, because every similar question was answered with altering class A, whereas i am not allowed to do so. But since there seems to be only reflection, this question can be closed. Thanks guys and gals.