简体   繁体   English

Eclipse java重构将私有方法改为public方法

[英]Eclipse java refactoring to change private method to public method

I forgot to add the public access modifier to my abstract methods of a super class - I'm assuming that the quickest way to fix this would be through some refactoring-type-thing but I can't figure out how. 我忘了将公共访问修饰符添加到我的超类的抽象方法中 - 我假设解决这个的最快方法是通过一些重构类型的东西,但我无法弄清楚如何。

My question is thus then: Does Eclipse have a way to change the access modifier of a method such that classes that implement it will be affected? 那么我的问题是:Eclipse是否有办法改变方法的访问修饰符,以便实现它的类会受到影响? And how do I use it if it exists? 如果它存在,我该如何使用它?

Thank you! 谢谢!

Right click on the method refactor -> change method signiture change access modifier to public. 右键单击方法refactor -> change method signiture更改访问修饰符更改为public。 I suggest doing this on the parent class method. 我建议在父类方法上执行此操作。

You can also open this config alt + shift + c keys if you are using default keys. 如果使用默认密钥,也可以打开此配置alt + shift + c键。

As a side note, when you dont specify any access modifier it will be package friendly. 作为旁注,当您不指定任何访问修饰符时,它将是包友好的。 Also abstract methods can not be private. 抽象方法也不能是私有的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM