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

What is a parameter in a function?

507


What exactly is methodology?

457


What are the various access specifiers in java?

545


What is a parameter in matrices?

517


Is array primitive data type in java?

512






What are wrapper classes in java?

570


What is unicode with example?

596


How many types of flags are there?

496


Do I need to import java.lang package any time? Why?

713


Explain about features of local inner class?

571


Write an algorithm for quick sort?

595


What is the use of generics? When was it added to the Java development Kit?

529


Wha is the output from system.out.println(“hello”+null); ?

661


What is the order of arraylist in java?

586


What is a string token?

517