How extract private static constant in Intellij Idea?

JavaIntellij IdeaRefactoringKeyboard ShortcutsConstants

Java Problem Overview


To extract constant I can use ctrl + alt + c, that "extraction" create public constant:

public static final String CONST = "123";

So I need manually type private. Is there a way to extract constant with private scope by default?

Java Solutions


Solution 1 - Java

Hit ctrl+alt+c twice (shows Extract Constant dialog)

hit alt+v (set default Visibility to Private)

hit enter

Done :) The private scope is set default - so you can use constant extraction as before, to change default scope simply repeat steps above with choosing different scope.

Solution 2 - Java

Try this:

> If the Enable in place refactorings check box is cleared on the Editor > settings, the Extract Constant refactoring is performed by means of > the Extract Constant Dialog dialog box.

http://www.jetbrains.com/idea/webhelp/extract-constant.html

Extract Constant Dialog allows choose the appropriate scope of constant

Settings -> Editors -> Enable Place refactoring

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionCherryView Question on Stackoverflow
Solution 1 - JavapbaranskiView Answer on Stackoverflow
Solution 2 - JavakemenovView Answer on Stackoverflow