File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

inner class ?!

 
Hychin
Greenhorn
Posts: 4
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 23
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 60
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can also use B.this directly to access the current instance of the outer class.

Alex
 
Hychin
Greenhorn
Posts: 4
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks, alex
A a = new A(B.this); // works well and convenient
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic