Solved

"Inspection" of other classes

Posted on 2004-04-21
4
273 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

ScreenConnect 6.0 Free Trial

Explore all the enhancements in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI, app configurations and chat acknowledgement to improve customer engagement!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
ForLoop Example 3 49
javap bin 2 36
how to add new optional parameter to JSP 1 42
Groovy problem when using SOAPUI : DispatchException occurred 7 46
This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.

831 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