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
What does exp mean in math?
How do you sort arrays in java?
When is the arraystoreexception thrown?
How do weakhashmap works?
What is array list in java?
Is there any difference between synchronized methods and synchronized statements?
How to display names of all components in a Container?
How do you check if a string contains only numeric digits?
Is null false in java?
What does jre stand for?
What is meant by anonymous class?
What is flush () in java?
FOR EXAMPLE WE R HAVING TWO LIST ELEMENTS ..BOTH LISTS CONTAINS ID,NAME,PLACE ..I NEED TO COMPARE BOTH IDS IN TWO LISTS,IF ID'S R SAME MEANS WE HAVE ADD THE DETAILS(LIKE NAME,PLACE) TO MAP...HOW IS POSSIBLE ?CAN ANY ONE SUGGEST?
What is the purpose of using break in each case of switch statement?
Is string pool garbage collected?