Is it possible to write method inside method
Answers were Sorted based on User's Feedback
Answer / divya
no,it's not possible to write method inside a method.it
will gives an error illigal starts of expression
| Is This Answer Correct ? | 18 Yes | 4 No |
Answer / 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 |
How to reverse a string in java?
How to create a base64 decoder in java8?
Can It is possible to synchronize the constructor of a Java Class?
How thread scheduler schedule the task?
What is the difference between @before and @beforeclass annotation?
After compilation of java program we'll get .class code. If it's generated in OS Windows XP will it work on OS Linux? If yes why? If no why?
Write the algorithm to check the number non-leaf nodes in a tree.
Explain jvm, jre, and jdk?
Which number is denoted by leading 0x or 0x in java?
How to sort an array in java without using sort method?
difference between jsp and java script?
What java is used for?