Automatic variable expansion in IntelliJ

I work in a Java store this summer, and I'm coming from a C # job. I got super by simply typing var x = randomMethod(); IntelliJ has one way or another to print something like this, and then automatically go to the correct return type after pressing input. So something like var x = newStringList(); becomes List<String> x = newStringList();

+4
source share
1 answer

Rumel, welcome to the java world, and it's easy ...

First enter the name of the method (start typing it and use Ctrl + Space to autofill if you want ...)

 newStringList() 

Using the cursor on the method or parenthesis, now press Ctrl + Alt + V (refactor: Imagine the variable) and enter the desired variable name (instead of the default value, which is equal to strings ).

 List<String> strings = newStringList(); 

Good luck

+5
source

Source: https://habr.com/ru/post/1489568/


All Articles