Intention - Itroduce local variable use local type inference

已回答

Is there any way to make IntelliJ use var instead of type when using "introduce local variable" intention?

An example would be something like this:

1. Write a code
List.of(1, 2, 3);

2. Use shortcut 'alt + enter' -> introduce local variable. The result is:

List<Integers> integers = List.of(1,2,3);

 

Is there any way to make IntelliJ put 'var' instead?

var integers = List.of(1,2,3);

3

I have IntelliJ IDEA 2019.1.3 (Ultimate Edition) Build #IU-191.7479.19, built on May 28, 2019 JRE: 1.8.0_202-release-1483-b58 amd64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
Windows 10 10.0

Can i now press alt+enter and declare var types where possible? I saw i can add checkbox "Declare var type", but how can i declare it automaticly whiout chekbox ?

0

Hello,

You need to use the checkbox just once (you may quickly select the Declare var type option with mnemonic Ctrl+Alt+V), during the next refactorings state of this option will be saved, so there will be no need to check the option again.

1

请先登录再写评论。