1

Suppose there is a class :

class A {
  int a;
}

And then there is a child of class A :

class B extends A {
  int b;
}

if i call B.class.getDeclaredFields() i'll only get 'b' field.

Now how can i get fields of parent class in this case 'a'.

VishalDevgire
  • 4,232
  • 10
  • 33
  • 59

1 Answers1

13

You should call it with something like this:

B.class.getSuperclass().getDeclaredFields();
Random42
  • 8,989
  • 6
  • 55
  • 86