File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes inner class  ?! Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "inner class  ?!" Watch "inner class  ?!" New topic
Author

inner class ?!

Hychin
Greenhorn

Joined: Mar 25, 2002
Posts: 4
class A {
public A (B b) {}
}
class B {
class Inner {
public void function () {
A a = new A(?); // How to create object a
...
}
}
}
John Williamer
Greenhorn

Joined: Mar 27, 2002
Posts: 23
I'm not sure if this is what your after but here goes:
class A {
public A (B b) {}
public A (){}
}

class B {
B h=(B) this;
class Inner {
public void function () {
A a = new A(h); // How to create object a
}
}
}
Hope this helps
alex earnshaw
Ranch Hand

Joined: Nov 05, 2001
Posts: 60
You can also use B.this directly to access the current instance of the outer class.

Alex
Hychin
Greenhorn

Joined: Mar 25, 2002
Posts: 4
thanks, alex
A a = new A(B.this); // works well and convenient
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: inner class ?!
 
Similar Threads
inner class shadowing
Top-level classes
"inner class"
Inner class
Inner Classes