如何在Intellij Idea中提取私有静态常量?

Che*_*rry 45 java refactoring keyboard-shortcuts const intellij-idea

要提取常量,我可以使用ctrl+ alt+ c,即"提取"创建公共常量:

public static final String CONST = "123";
Run Code Online (Sandbox Code Playgroud)

所以我需要手动键入private.有没有办法默认使用私有范围提取常量?

pba*_*ski 79

ctrl+ alt+ c两次(显示Extract Constant对话框)

点击alt+ v(默认设置VisibilityPrivate)

击中 enter

完成:)私有范围设置为默认 - 因此您可以像以前一样使用常量提取,更改默认范围只需重复上述步骤并选择不同的范围.