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 set string?
What is an array and a vector? How they different from each other?
What is a method type?
WHAT IS THE SCOPE FOR COREJAVA...? IS JAVA ONLY CORE JAVA ?
Is char a data type in java?
How do you access command-line arguments within the code?
0 Answers Flextronics, Hexaware,
What is gc()?
Name the types of mouse event listeners ?
How to implement an arraylist in java?
What is downcasting?
Why Set interface contains unique elements, what internally implemented for this so that it contains unique elements?
why the equals method can be override?when we override the equals method?