in Java, non- final
variables use the naming convention of an uppercase for every first letter of a word: myInteger
.
final
variables use all uppercase letters and an underscore for word separation: MY_INTEGER
.
In Eclipse, one can rename a varialbe using Alt + Shift + R and that takes care of all references. My question is: is there a way to easily rename a varialbe between the final
and non- final
styles. Otherwise, I need to retype more or less the whole name.
If I understand your question correctly this is what you are expecting: an automatic way of changing the coding style of a name used for a variable (I'm skipping the word final deliberately, because final means its value can't be changed and thus not a variable). That is, MY_INTEGER to myInteger and vice versa . If that's correct then I think the answer is no in Eclipse.
You can use the "rename" refactoring feature of the IDE to change the variable name. You cannot change the "style" of a name in Java because that is not a Java concept. What you change is the name of the variable.
Also, you don't use uppercase-plus-underscore names for final
variables, you use them for constant variables, or by extension, final
references to immutable objects. final
references to mutable objects use camel case with an initial lower-case letter. Not all final
variables are constants.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.