Features

Java 8 and Method References in IntelliJ IDEA 12

As you might know IntelliJ IDEA 12 will bring support for new features of Java 8 language. Though this is still in progress, you can try some of these features now in IntelliJ IDEA 12 EAP.

Here we would like to provide some details on method and constructor refereces support.

IntelliJ IDEA as always provides a way to transform existing code to use new features. Dedicated inspection finds and highlights anonymous types which can be replaced with a method reference.

After you apply provided quick-fix, it gets just a line of code.

There is also another inspection that checks if a lambda expression in your code can be replaced with a method reference.

You can also use an intention  to replace a method reference with a lambda expression, in the case when you need additional logic.

All the common features such as completion, refactorings, formatting and many other were updated to support method and constructor references.

As always you are very welcome with suggestions and feedback in our issue tracker.

Develop with Pleasure!

image description