Solved

"Inspection" of other classes

Posted on 2004-04-21
4
274 Views
Last Modified: 2011-04-14
Hi,

Is there a way to get the names of methods and attributes of other classes  (also if they are declared private)?

Lets fx. say that I would like to list all the attribute names(and values), and method names from the Color class.

What would I do??

Kind regards,

Nic
0
Comment
Question by:JNic
  • 2
4 Comments
 
LVL 1

Accepted Solution

by:
ACrasborn earned 100 total points
ID: 10877769
Try this:

        Class c = Color.class;
        Method[] m = c.getDeclaredMethods();
        Field[] f = c.getDeclaredFields();

You can find more information in package "java.lang.reflect"

A.C.
0
 
LVL 37

Assisted Solution

by:zzynx
zzynx earned 25 total points
ID: 10878225
"Reflection" is the word.
You can even invoke the methods you found this way.
Read all about it at http://java.sun.com/docs/books/tutorial/reflect/
0
 
LVL 1

Author Comment

by:JNic
ID: 10878287
Ahhhhhhhhhhhh :-D

Thank you both! I LOVE THIS PLACE!!!!

Kindest regards,

Nic
0
 
LVL 37

Expert Comment

by:zzynx
ID: 10878374
Thanks for accepting
:)
That keeps us answering your future questions too
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

For customizing the look of your lightweight component and making it look lucid like it was made of glass. Or: how to make your component more Apple-ish ;) This tip assumes your component to be of rectangular shape and completely opaque. (COD…
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
The viewer will learn how to implement Singleton Design Pattern in Java.
This video teaches viewers about errors in exception handling.

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question