We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Java Reflection - Attributes
Java Reflection - Attributes
Sort by
recency
|
122 Discussions
|
Please Login in order to post a comment
There is a mistake in the problem description: It's written: JAVA reflection is a very powerful tool to inspect the attributes of a class in runtime. For example, we can retrieve the list of public fields of a class using getDeclaredMethods().
It should be one of:
So, both methods return not only public fields/methods, but all fields/methods except inherited ones. And, appropriately, we have to use getDeclaredFields() for the fields, and getDeclaredMethods() for the methods.
Just to mention to either run the code using Java 7 or add the following methods for the Student Class, as they are also required for the output assertion:
Bumping to top.. to say this only works in Java 7.