Place your text ad here.
Web hosting directory, find affordable web hosting
Data recovery software tools & file recovery utilities to recover lost data
WestNIC provides reliable web hosting services
SGD Networks offers Web Hosting, Web Hosting Hyderabad
Award Winning PST Repair and Mail Recovery Software
This answer is part of the Code Style premium content package. You must have a premium content subscription to log in and view the full answer to this question. Use the premium content subscription form below.
A: It is possible to deduce the inherited fields and methods of a Java class using reflection through a recursive process that uses the Class method getSuperclass(). The Class method getFields() returns an array of Field objects for public fields only. The getDeclaredFields() returns an array of all declared fields in the current class, including private fields, but not the inherited fields. The getMethods() and getDeclaredMethods() methods return equivalent arrays of Method objects.
To obtain a list of all inherited fields or methods, a program would need to get the superclass of the object in question, store the return value for its getDeclaredFields() method then process each of its superclasses in turn. The simple example below prints out all the inherited fields in its immediate superclass Thread.
More details available to subscribers:
How can I find the inherited attributes of a class?
You must make a subscription payment to access areas flagged premium content. Use the form below to create an account via PayPal.
The PayPal service allows you to pay securely and independently in your own currency. Payments are billed to Metacentric Internet Limited. We never handle your credit card details.
The Code Style site has accumulated 8 years' worth of answers to the most common Web development questions. Answers are written in clear English with examples and links to other Web resources. Your subscription provides full answers to all premium content questions listed below (and other FAQ sections), plus:
double up to an int?
NumberFormatException back to the main() method?
println overloading or overriding?
public static void main(String[]) mean?
hashCode() used?
NullPointerException in Java?
Rectangle on a Graphics instance?
new operator?
Class.forName() method and the new operator?
Class.forName() scheme?
newInstance()?
Class.forName() runtime polymorphism?
Class.forName(dbDriver) work with DriverManager.getConnection?
Statement and PreparedStatement?
PreparedStatement?