How to generate the method stubs for all un-implemented methods in interfaces/abstract classes using eclipse?

北城余情 提交于 2019-12-24 14:10:32

问题


In eclipse I have the following problem very often while writing java code: While coding (especially in the early time of coding) I often have to change interfaces until everything fits well. If I change such a Superclass I have to modify every single Subclass to implement the method.

This is clearly necessary to make the whole code run but I would like to test things without having to code every in a single bit. Further the trick with

  • Opening the class
  • Clicking on the (errorous) class name
  • ressing <Alt>+<1> and selecting Implement all un-initialized methods

takes quite some time when I have to do it many times.

Is there a way to select all related classes and click in the IDE on some magical menu to generate all non-implemneted methods in these classes as stubs?


回答1:


The problem is not IDE that do not provide the support for such action. But the way your coding looks, that needs to improve.

An alternative for you may bring Java 8 where you can use the default methods implementation for interface.

Then you will no longer have to update child classes.



来源:https://stackoverflow.com/questions/23358879/how-to-generate-the-method-stubs-for-all-un-implemented-methods-in-interfaces-ab

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!