Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Intellij - is there autocomplete for the type of a for loop?

like in eclipse, if you wrote a for loop like this:

for (name : names)

eclipse auto complete would let you add the type, so you'll get:

for (String name : names)

is there a similar feature in IntelliJ?

normal auto complete CTRL+SHIFT+SPACE or CTRL+SPACE aren't working.

like image 658
shemerk Avatar asked Dec 13 '15 07:12

shemerk


People also ask

Does IntelliJ have autocomplete?

Invoke basic completion By default, IntelliJ IDEA displays the code completion popup automatically as you type. If automatic completion is disabled, press Ctrl+Space or choose Code | Code Completion | Basic from the main menu.

How do I enable auto suggestions in IntelliJ?

Configure completion options 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.

How does code completion work?

Intelligent code completion uses an automatically generated in-memory database of classes, variable names, and other constructs that given computer code defines or references.


1 Answers

I'm not familiar with the equivalent eclipse feature, but the closest thing I can think of (or alternative solution) is to use postfix completion.

if you type

names.for

and select the first suggestion, it will auto-expand into

for (Object name : names) {

}  

and it will automatically add the type of name for you, based on what the collection type of names is.

like image 113
matmo Avatar answered Sep 22 '22 05:09

matmo