How can I refactor(move) a Java method in classA into classB and have all references to the method to it updated?
Is this supported in Eclipse ?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
For a static method, you can right click and select ‘Move’.
would then get ‘moved’ to
and eclipse would fix your imports etc.
For a non-static method, this may not work depending on the relationship between classA and classB.
If you move myMethod() to a different class, the refactoring would have to change the object initialization. If myOtherMethod isn’t getting moved, then it can’t just change the type of myobj1 to Obj2 because then myOtherMethod won’t work.