Question

I have some Java files that use the same String values up to 20 times each, and I want a tool that replaces those Strings with a private static final String STRING_TO_CAPS_AS_CONSTANT or something along those lines. If it can also convert numbers into magic numbers, that would be great. I'm using Eclipse but if it's a standalone tool I can still make use of it.

Était-ce utile?

La solution

I think Eclipse provides that already. If you select the whole String and press CTRL+1 it should give you the opportunity to choose: "Extract to constant". This will implicitly replace all occurrencies of your String with the new constant.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top