Reputation: 1451
i am trying to pass method local inner class object as an argument 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?
Upvotes: 0
Views: 5725
Reputation: 1503639
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.
Upvotes: 7