Reputation: 13965
I have the following arrangement (not showing all fields and methods):
public class MyClass implements myClassInterface{
public static MyClass getInstance(){
return INSTANCE;
}
public class Inner implements innerStuff{
@Override
public void doInnerWork(Object param){
}
}
}
I need to access doInnerWork(param)
. How do I do that? I try many things but they all fail including:
new (MyClass.getInstance().Inner()).doInnerWork(param);
thanks for helping.
Upvotes: 1
Views: 590
Reputation: 31699
To create an instance of a nested class Inner
, where you want it to be nested inside some object obj
, the syntax is
obj.new Inner()
So in your case you probably want
MyClass.getInstance().new Inner().doInnerWork(param);
I'm not saying this will give you the results you want, but that's the syntax.
Upvotes: 0
Reputation: 18286
MyClass.getInstance().new Inner().doInnerWork(param);
Note that this will create a new inner class every time (it won't be a singleton).
Upvotes: 4