Selasa, 27 Juli 2021

What is Effectively Final variable of Java 8? Example

Apart from the big three, Lambda expression, Stream API, and new Date and Time API, Java 8 has also introduced a new concept called the "effectively final" variable. A non-final local variable or method parameter whose value is never changed after initialization is known as effectively final. It's very useful in the context of the lambda expression. If you remember, prior to Java 8, we cannot use a non-final local variable in an anonymous class. If you have to access a local variable ( a method parameter or a variable decreed in the method itself) in the Anonymous class, you have to make it final. This restriction is relaxed a bit with lambda coming up. Java designers have taken the need to make local variable final if it's not changed once initialized.

Lorem ipsum is simply dummy text of the printing and typesetting industry.

Comments


EmoticonEmoticon