• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Challenging tasks GUY ,Please Help Me

 
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I have a Main Class and from there i am calling another class by creating an object.
like this
Class MainClass
{
SubClass subObj = new SubClass();
MainClass()
{}
public static void main(String args[])
{
new MainClass();

}
}
Now the problem is i have to access some components of the MainClass without
Creating an object of the MainClass remember that i don't even want to do Extend the MainClass to SubClass(This is for some other reson).
if atall i create an Object of MainClass in the SubClass then it will create another Object ...
think that i want to add a table to the panel in the main class...
and later i want to remove it from the SubClass then it is will simply give
NullPointerException....
Please let me know ur solutions on this...

Summary:
I want to access the back class object without creating a new Object for that, it means i want to access the back class object the same object which is pointed by the backclass....
Please resolve this
bye
naryana
 
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What If you pass the reference of Object of main class to the constructor of subclass object like this
MainClass(){
Subclass sub = new SubClass(this);
}
-Mahesh
 
reply
    Bookmark Topic Watch Topic
  • New Topic