IntelliJ IDEA 2017.3 EAP brings support for Local-Variable Type Inference

IntelliJ IDEA 2017.3 EAP brings support for Local-Variable Type Inference.

A long-awaited Java 9 has been released just a few weeks ago, but we’re already looking forward to the new goodies Java 10 is going to bring. Though the chances are it might not be called Java 10. Oracle has proposed moving Java to releases every six months, so we might have the next release already as early as March 2018, and will probably be named Java 18.3. We’ll see.

The upcoming release of Java is going to bring Local-Variable Type Inference according to the JEP 286. This specification aims to reduce the boilerplate code while declaring local variables.

IntelliJ IDEA 2017.3 supports Local-Variable Type Inference. The IDE will include a prompt to replace the explicit types with ‘var’, when the type can be inferred from the context.

inspection-LVTI
Currently the IDE detects local variables with ‘var‘ types when they can be replaced with explicit types.

var-explicittype

This new feature allows you to sneak-a-peek into the future Java release, so we hope you’ll give it a try. As this is an experimental feature, we count on your feedback a lot. But please keep in mind that the JEP 286 has not been released yet so it might still change, and if so, the support for this feature in our IDE will be changed accordingly. Do share your thoughts with us here in the comments, on twitter or in our issue tracker.

Happy developing!

 

 

About Zlata Kalyuzhnaya

IntelliJ IDEA Marketing Manager at JetBrains.
This entry was posted in EAP Releases, New Features and tagged , , , , . Bookmark the permalink.

10 Responses to IntelliJ IDEA 2017.3 EAP brings support for Local-Variable Type Inference

  1. Josh says:

    As a C# dev turned Java dev, why not do something that would work before Java 10 gets a release? Hide the variable declaration when it’s obvious from context so that we get to see this feature today (but still save the correct type to the file). A few of the long time Java devs that I work with are unconvinced of the need for the var functionality in the language. This would go a long way to showing them that it works well in practice and reduces the noise when reading code.

  2. Brice says:

    404 not found on the screenshot

  3. Sarah says:

    I’m mainly a Java developer, but have a small bit of experience with C#. I hope that this does not over emphasize the use of the ‘var’ keyword like what ReSharper does in Visual Studio, or I may end up having to completely disable it.

    I’m not opposed to using it, but I know that my coworkers are going to throw a fit if they see it used liberally.

  4. Mateus says:

    I’m trying testing this new feature but I can’t. It doesn’t work.

Leave a Reply

Your email address will not be published. Required fields are marked *