> Hi there
>
[quoted text clipped - 16 lines]
> I need some help with this. Is there a way to list all the objects
> used in your program (modifying the objects are allowed).
While it is possible to list all the _fields_ in your class, you would not
want to do this. I am pretty certain this (homework?) task is meant another
way. Especially since you seem to be entirely in your main method...
But it is really hard to say, since you did not provide much information.
You
basically say "I need to do something with some objects. How do i do it?"

Signature
Whom the gods wish to destroy they first call promising.
> I need some help with this. Is there a way to list all the objects
> used in your program (modifying the objects are allowed).
This has nothing at all to do with assertions, then. The answer is that
there is no "normal" way to list all objects in a Java program. You
almost certainly wouldn't care about most of them anyway, since they'd
be used internally by the JVM and not related to your application. You
should instead keep track of just those objects that you do care about,
for example by keeping a list of WeakReference instances that you update
from the object's constructor.
It would be possible to use JVMTI (or one of its predecessors, JVMDI or
JVMPI) to list all the objects in the VM, but this is generally a poor
idea from real code; that API is meant for use by debuggers, profilers,
and other such tools.

Signature
www.designacourse.com
The Easiest Way to Train Anyone... Anywhere.
Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation
Richard - 27 Sep 2004 17:34 GMT
cdsmith@twu.net wrote...
> > I need some help with this. Is there a way to list all the objects
> > used in your program (modifying the objects are allowed).
>
> This has nothing at all to do with assertions, then.
Pity, too. As a C programmer with some OOP background, picking up
Java, assertions in Java has been on my list of things to find out
about once I get other, more fundamental things, under my belt.
Lāʻie Techie - 27 Sep 2004 20:16 GMT
> Pity, too. As a C programmer with some OOP background, picking up Java,
> assertions in Java has been on my list of things to find out about once I
> get other, more fundamental things, under my belt.
http://java.sun.com/j2se/1.4.2/docs/guide/lang/assert.html
HTH,
La'ie Techie