How to call methodTwo(); from methodOne(); ?
class Name {
void methodOne() {
class InnerClass {
void methodTwo() {
}
}
}
}
Thank You!
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You need to create an instance of the
InnerClass, in the same way as any other instance method needs an instance on which to call it:It’s worth being careful before doing this – I don’t think I’ve ever seen a named class declared within a method in the production code I’ve been associated with. Normally I’d either use an anonymous inner class for something really short, or a private static named class for anything longer, to avoid making the method too long.