I'm refactoring my java code with IntelliJ and need to add an extra parameter on a constructor.
Let's say I'm editing the class SocialNetwork and just changed how I add a friend, instead of just a name now the class also has an Integer that is the age.
Of course IntelliJ will tell me the constructor doesn't exist. So far so good.
Now the problem, on Eclipse it is possible to choose among create a new constructor or change the existing one. When I hit Alt+Enter on IntelliJ I only get the option to create a new constructor.
Is there a way for IntelliJ for offer the option do add an Integer parameter to the existing constructor?


Intellij treats constructors just like regular methods, so the same refactoring procedures apply to constructors (save for a few caveats, like editing the name)
You can use Refactor -> Change Signature... to add and remove parameters, by accessing either from the definition, or any statement that uses new

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With