Note: I found multiple information about disclose (get) value of protected fields or members of some class, my difference its a need to obtain of instanced objects...
Hi, I want to disclose information the previously instanced static Inner class (Object previously created)...
static public class Outer {
static class Inner {
protected int number = 0;
protected int times = 2;
public Inner(int number) {
this.number = number;
}
}
}
Outer.Inner oi = new Outer.Inner(8);
I want to print the value of instanced Class, because I don't know how was instanced (what argument was passed).
How?
I was thinking something...
class Another extends Outer.Inner {
Another(int j) {
super(j);
}
public void submit() {
System.out.println("the constructor argument was:" + number);
}
}
In other class, of my own project I'm using 'oi', but I need to reveal its information (I don't want to change the original class) and to find where is the object created.
Is there a solution to accomplish this?
Another a = (Another)oi;
a.submit(); // I want to print the original argument.