Skip to content

Instantly share code, notes, and snippets.

@MarkMenard
Created October 8, 2010 20:53
Show Gist options
  • Save MarkMenard/617525 to your computer and use it in GitHub Desktop.
Save MarkMenard/617525 to your computer and use it in GitHub Desktop.
public class A {
private String foo = "A";
public void printFoo () {
System.out.println(foo);
}
}
public class B extends A {
private String foo = "B";
public void printFoo () {
super.printFoo();
System.out.println(foo);
}
public static void main (String[] args) {
B b = new B ();
b.printFoo();
}
}
// When run B outputs:
// A
// B
// So the foo in A exists in some way inside an instance of B. How do I get
// to it through reflection.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment