I'm using IntelliJ IDEA 13 with Java 8 and wonder how to autocomplete lambdas. Before Java 8 I used anonymous inner classes of course. I auto completed by typing "new" and hitting Ctrl+Space:
and choosing the first option.
Now with Java 8 I want to generate lambdas as well, inferring parameters and all, but I can't find autocompletion for it.
Note, this above example is quite easy, but when you have multiple parameters with generic types, e.g. JavaFX Listeners and the like, autocompletion comes in handy.
By default, IntelliJ IDEA displays the code completion popup automatically as you type. If automatic completion is disabled, press Ctrl+Shift+Space or choose Code | Code Completion | Type-Matching from the main menu. If necessary, press Ctrl+Shift+Space once again.
I have tried the following according to this thread (Intellij IDEA CE 12 Android XML Code Completion not working): Go to File->Power Save Mode and disable it - it is off. Go to Preferences->Editor->Code Completion and check Autopopup code completion - this has been checked. Go to File->Invalidate Caches and restart.
Press Ctrl+Alt+S to open the IDE settings and select Editor | General | Code Completion. To automatically display the suggestions list, select the Show suggestions as you type checkbox.
Start the IDE, Help | Find Action (Ctrl+Shift+A or Cmd+Shift+A on Mac), type "Switch IDE Boot JDK", press Enter. Start the IDE, use Help | Find Action (Ctrl+Shift+A or Cmd+Shift+A on Mac), type "Switch IDE Boot JDK", press Enter. Switch IDE Boot JDK dialog appears.
In Windows or Linux, it’s Ctrl+Space
In Mac OS, it’s Ctrl+Shift+Space
You can just type p = s -> f...
, autocompletion will then suggest false
. If you're not sure about lambda, you can start with the inner class, and then turn it into a lambda expression.
In your example you can press Alt+Enter afterwards, as follows:
After completing:
After pressing Alt+Enter:
Result:
Clicking the small icon at the gutter shows you the Predicate.test
method.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With