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
Lowest Common ancestor in a Binary Search Tree and Binary Tree.
Why parameters should be passed by reference?
What is integer valueof?
Can we execute a program without main?
Can we extend singleton class in java?
How do you use wildcards?
Is string an object?
What is extension method in java?
When throw keyword is used?
What is the old name of java?
What is array length in java?
How to perform bubble sort in java?
What are the characteristics of Final,Finally and Finalize keywords.
How do I know if java is installed?
what is the use of bean managed and container managed with example?