Is it possible to write method inside method

Answer Posted / janeesh

it is possible to write a method inside a method by using
method local inner classes.
Eg:
class Outer {


public void display() {
System.out.println("This is outerclass method.");

class Inner{

public void displayInner()
{
System.out.println("innerclass method");
}

}
Inner objC = new Inner();
objC.displayInner();
}
}
class MethodeInsideMethod {
public static void main(String[] args) {
Outer objC = new Outer();
objC.display();
}

}


Output:
This is outerclass method.
innerclass method

Is This Answer Correct ?    11 Yes 5 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Lowest Common ancestor in a Binary Search Tree and Binary Tree.

737


Why parameters should be passed by reference?

676


What is integer valueof?

834


Can we execute a program without main?

716


Can we extend singleton class in java?

720






How do you use wildcards?

722


Is string an object?

845


What is extension method in java?

764


When throw keyword is used?

778


What is the old name of java?

682


What is array length in java?

694


How to perform bubble sort in java?

764


What are the characteristics of Final,Finally and Finalize keywords.

904


How do I know if java is installed?

743


what is the use of bean managed and container managed with example?

1698