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.
MyClass.getInstance().new Inner().doInnerWork(param);
请注意,这将每次创建一个新的内部类(它不会是单例)。
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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.