Java type hints in IDEA

Posted by Java developer blog on June 30, 2019

Java 10 introduced a new var keyword that allows you to not declare type explicitly.

I am not going to discuss the pros and cons of the feature. You could read about it more here if you want.

However, it is possible to show the real type instead of a var keyword.

I checked this feature with IDEA 2019.1. To enable the feature use the following steps below.

Firstly, look at the simple example below

You could see that the example covers both const and not const cases.

Secondly, you have to open parameters in Settings/Editor/General/Code Folding, then check Replace ‘var’ with inferred type. Look at the image below.

Then reopen a file if needed.

In the end, you will get the result like this below.