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 |
give me the answer of this code class A extnds String This code we can write r not in Java? Explain?
What does microservices mean?
What is the best way to findout the time/memory consuming process?
Explain about core java?
How to calculate the length of a singly linked list in java?
Can we make constructors static?
In what types of operations an ArithmeticException will be thrown?
Explain the difference between arraylist and linkedlist in java?
What is an exception in java?
Which method is used to find that the object is exited or not?
Is multiple inheritance allowed in Java? Why ?
java is pure object-oriented programming language?why it is platform independent.