Var in java?
If you are like me who picked up java when it was released a quarter of a century back, chances are that you will appreciate this.
The backend for one of our projects is in java and spring boot. As part of best practices of software development, we configured our code to be analysed by Sonarqube, an awesome tool for code quality.
As we looked at the different types of issues reported by the tool, we spotted this one
Declare this local variable with “var” instead.
Hey, was I reading this right? This is java code and not javascript, right? Even in javascript, we now should be using let and const to scope the variables correctly. var in java? On clicking the Why is this an issue? link, we were presented with more details.
Quoting from the details displayed by Sonarqube
Local-Variable Type Inference should be used
Boy, weren’t we glad we decided to use Java 11, rather than Java 8 to build this application? As you can see above, this feature came into Java in Java 10.
Comments are closed.