Justify your answer that you can't define a method inside another method in java, if you can then how?
Answer / Preet Banga
In Java, it is not possible to define a method inside another method. Methods are declared outside of methods and classes. If one tries to declare a method within another method, the compiler would produce an error.nHowever, you can achieve similar functionality using lambda expressions or anonymous inner classes in Java 8 or later.
| Is This Answer Correct ? | 0 Yes | 0 No |
Can there be an abstract method without an abstract class?
what is difference between method overloading & method overridding with example?
Does .length start 0 java?
How to reverse string in java?
public class Test { public static void main(String ar[]) { Integer a = 10; Integer b =10; Integer c = 145; Integer d = 145; System.out.println(a==b); System.out.println(c==d); } }
How can we create a synchronized collection from given collection?
Explain the differences between public, private, protected and static?
How do I run java on windows?
How many times garbage collector will invoke an object?s finalize() method?
What is the default size of arraylist in java?
what is the collable collections in java?
What are the different types of multitasking?