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 foreach loop in java?
What is the disadvantage of java?
What are data types in oop?
what is Assertion?
What is super?
What is the difference between the size and capacity of a vector?
What is difference between this and super keyword?
What is the use of static keyword in "public static void main()"
10 Answers College School Exams Tests, Infosys, Six Dee Telecom,
What are the approaches that you will follow for making a program very efficient?
class a extends b { } class b extends a { } why java doesn't support cyclic pls explain me with example
Why can't we make jsp as a controller and action servlet in struts?
Explain java coding standards for variables ?