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 do you create a first line indent?
What purpose do the keywords final, finally, and finalize fulfill?
How much is a java license?
How many types of constructors are used in java?
Tell me are there implementations for sorting and searching in the java libarary?
Why does java have different data types for integers and floating-point values?
What class allows you to read objects directly from a stream?
Define reflection.
What should I import for arraylist in java?
What is the difference between stringbuffer and stringbuilder class?
What about member inner classes?
What is numeric function?