I'm working at a Java shop this summer and I'm coming from a C# job. I got super used to just typing var x = randomMethod();
In IntelliJ is there anyway to type something like this and then have it automatically expanded to the correct return type after hitting enter. So something like var x = newStringList();
becomes List<String> x = newStringList();
Rumel, welcome to the java world, and this one is easy...
First, type the method name (start typing it and use Ctrl + Space to autocomplete, if you like...)
newStringList()
With your cursor still on the method, or the parenthesis, now hit Ctrl + Alt + V (refactor: Introduce Variable ) and type the variable name you want (instead of the default, which is strings
).
List<String> strings = newStringList();
Good luck!
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.