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 |
What is escape analysis algorithm in JVM and how garbage collection actually worked n how it transfer the objects from one kind of space to other?
How is treeset implemented in java?
What do you mean by object?
What are listeners in java and explain ?
What is a class in java?
What are checked exceptions?
Is null an object java?
What is deserialization and how do we do deserialization?
What is the inheritance?
How does serialization work
What is considered an anti pattern?
Why java uses the concept of the string literal?