Kirby Kirby - 1 month ago 7
Java Question

intellij have introduce constant be private not public

In Intellij IDEA 11.1.2, when using the refactor shortcut to Introduce a Constant, it always makes public static final constant, whereas I generally prefer to default to private.
In older versions of Intellij, I'm pretty sure that I had the option of setting private as the default.
Does anyone know if there still exists an option to default to private for the Introduce Constant refactor option rather than having to afterwards go to the declaration and edit the public to private?
Thanks

Answer

I had the same problem and solved it (idea 12).

To introduce private constants by default do the following:

  • Disable in-place mode (File -> Settings -> Editor -> uncheck "Enable in-place mode")
  • Try to introduce something (You will see a refactor dialog). Select "private" in that dialog
  • Enable in-place mode
  • Enjoy private constants