Swastik
For just creating an instance you dont need any relationship , you need relationship(extend another class) only when you need method overriding.
A a1=new A();//should solve your requirement.
Time is what we want the most, but what we use the worst. -- William Penn
Swastik
SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
A aref=//you should say how to fetch that from the heap
Swastik
ramya so you don't want a reference of an object in your class but you want to copy an instance of another class in your class.
Swastik
Time is what we want the most, but what we use the worst. -- William Penn
The obvious and simplest way is to pass a reference of the particular A instance into the B object.ramya narayanan wrote:We can create many instances of A & one particular instance has the state i as 10.
I want to use that A instance in my class B.
Both extending the same class is not a useful relationship unless the root class keeps a static list of all instances created (and that's incredibly unlikely).Note however classes A & B don't have any direct relationship between them.
Only thing they both have same super class Panel.
There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors