-->It’s a class without name.
-->Anonymous inner class can extend Abstract and concrete classes
-->Anonymous inner class can implement an interface that contains any number of abstract methods.
-->Inside anonymous inner class we can declare instance variables
-->Anonymous inner classes can be instantiated.
-->Inside anonymous inner class “this” always refers current anonymous inner class object but not
outer class object.
-->Anonymous inner class is the best choice if we want to handle multiple methods.
-->In the case of anonymous inner class at the time of compilation a separate Dot class file will be
generated (outerclass$1.class).
-->Memory allocated on demand whenever we are creating an object.
Lambda Expression
-->It’s a method without name(anonymous function).
-->Lambda expression can’t extend abstract and concrete classes.
-->Lambda expression can implement an interface which contains single abstract method (FunctionlInterface).
-->Inside lambda expression we can’t declare instance variables, whether the variables declare are simply acts as local variables.
-->Lambda expressions can’t be instantiated.
-->Inside lambda expression “this” always refers current outer class object that is enclosing class object.
-->Lambda expression is the best choice if we want to handle interface with single abstract method (FunctionalInterface).
-->At the time of compilation no dot class file will be generated for lambda expression it simply convert into private method outer class.
-->Reside in permanent memory of JVM (Method Area).
Thanks for reading. If you like this post please follow us for more updates about technology related updates.
No comments:
Post a Comment