开发者

java method local inner class

i am trying to pass method local inner class object as an argument开发者_JAVA百科 to some other function either in the scope of outside class or out of that class

public class MethodClass {
public void p(){
    class h{
        public void h1(){
            System.out.print("Java Inner class");
        }
    }
    h h2=new h();
}
}

here h2 i want to pass to any other function in the same class MethodClass or out of that class. can any one give me the procedure to pass the argument in that way?


If another method needs to know about the class, then you shouldn't declare it within a method, basically. Make it a nested class within the class itself, or even a top-level class.

I can't say I've ever used method-local class declarations.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜