Search code examples
javaintellij-idea

How can I default constants in IntelliJ to private?


When I am creating a constant in IntelliJ (using Ctrl+Alt+C), by default it is public static final. How can I make it private static final instead?


Solution

  • After Ctrl+Alt+C, press this shortcut again, which shows dialog with more options.

    There is a visibility section. If you select private here, it will be the new default when extracting constants the next time.

    See the IntelliJ IDEA documentation: https://www.jetbrains.com/help/idea/extract-constant.html

    introduce constant dialogue