1

Can I get a child attributte in parent class? I see in PHP5 OOP that getting child attribute in parent class is possible, but in Java, I do not know.

Andrew Marshall
  • 95,083
  • 20
  • 220
  • 214
Bagus Cahyono
  • 668
  • 2
  • 8
  • 17

1 Answers1

0

If you want the subclasses, look here.

Then you can use Reflection to get the fields and methods of each subclass:

for(Class c : subclasses) {
  for(Field f : c.getFields())
    // Do stuff with the fields
  for(Method m : c.getMethods())
    // Do stuff with the methods
}

You can look at the Java API entry on Class for more information.

Community
  • 1
  • 1
Jon Egeland
  • 12,470
  • 8
  • 47
  • 62