From the course: Learning Lombok: Streamlined Java Programming

Unlock this course with a free trial

Join today to access over 25,500 courses taught by industry experts.

Mutable local variables versus JEP 286 var

Mutable local variables versus JEP 286 var - Spring Tutorial

From the course: Learning Lombok: Streamlined Java Programming

Mutable local variables versus JEP 286 var

- [Instructor] With IntelliJ open and the project code 20204 begin Lombok demo loaded, let's take a look at the employee image service. This was a new class added in chapter two for this tutorial to demonstrate JEP 286 and Project Lomboks var type. According to the documentation, var works exactly like val except the local variable is not marked as final. Lomboks var is basically a mutable version of val since JEP 286 and the release of var type in Java 10, var is a keyword and so we cannot use Lombok.var in our current project. According to the chief developers I chatted with about this feature, Lombok.var is kept primarily for legacy code written around Java 6, 7, 8, and 9. You might think that industry code bases in production would be upgraded by now, but the thing is there are various reasons at each software development shop why they're using a JDK prior to 10. As such, Loach maintains this backward compatibility for…

Contents