Hi, I'm trying to print out the methods of a class, I have a simple java bean with two properties, say, "name" and "address" and corresponding getters/setters. Then I initialize a class passing a reference to this object into its constructor and call a method that's supposed to loop over the bean's methods and print out their names... piece of cake.
The problem is that it prints out only the methods of the superclass Object not of the real runtime class. Here's a snippet of my code:
I'm stuck, can you give me some help? Thanks. [ December 17, 2004: Message edited by: Lukas Alamar ]
How are you running this? It seems to print out the Object methods last, so if your console doesn't have enough buffer space, then you might only see the Object methods, even though it printed out everything.
I tested this code, and it works:
and the results:
Piscis Babelis est parvus, flavus, et hiridicus, et est probabiliter insolitissima raritas in toto mundo.
Class.getMethods() only finds public methods, but does include inherited methods. On the other hand, Class.getDeclaredMethods() finds all methods (private, package, protected...), but does not include inherited methods (you can get those from the superclass Class object, though).
Does this help at all?
Betty Rubble? Well, I would go with Betty... but I'd be thinking of Wilma.