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.
Asked
Active
Viewed 149 times
1
-
What have you tried? Do you have an example of what you're trying to do? Why are you trying to do this? – Jeffrey Mar 14 '12 at 02:05
-
You need to give a specific example of what you are trying to do. – Hunter McMillen Mar 14 '12 at 02:07
1 Answers
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