By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,032 Members | 825 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,032 IT Pros & Developers. It's quick & easy.

List Variables & Type

P: n/a
Is it possible to extract all the used variables (&type) from a piece of
sourcecode, rather than doing it manually?

Cheers,
Dave
Jul 17 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
It is not clear what you mean exactly by "extract all the used variables
(&type)".

Dave wrote:
Is it possible to extract all the used variables (&type) from a piece of
sourcecode, rather than doing it manually?

Cheers,
Dave

Jul 17 '05 #2

P: n/a
nos

"Dave" <bigdavepotnoodle*SPAM*hotmail.com> wrote in message
news:3f***********************@news-text.dial.pipex.com...
Is it possible to extract all the used variables (&type) from a piece of
sourcecode, rather than doing it manually?

Cheers,
Dave

Suppose your class is Plot1();
You can use reflection class methods.
The following (needs to be tested)
fragment prints out all fields. Also
look at "getFields()"
It gives you something like this:
private static AlignRight Plot1.ar
for each field.
----

Plot1 p1 = new Plot1();
Class className = p1.getClass();

Field[] fields = className.getDeclaredFields();

for (int i = 0; i < fields.length; i++) {
System.out.println(fields[i]);
}
Jul 17 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.