I'm wondering whether is possible to access to the information contained in a field of a class from another class that's been created inside of the first one. I put a snippit of Java code for showing I want to do.
public class A {
public String c = new String();
B b;
...
...
...
public void doSomething() {
b = new B();
}
}
public class B {
...
...
...
public void retrieveInformationFromA() {
// I need to retrieve the field "c" of A instance that's
// created the B instance
}
}
NOTE: Due restrictions of the current design of this code I can't to create a constructor in B that includes a parameter for field "c" of A class. Due to legacy code, I have to avoid changing the existing code as much as possible.
I appreciated any help!!
UPDATE: I've corrected the code, I forgot to add the public modifier to the field "c" in A.