问题描述
在eclipse中,我在编写Java代码时经常遇到以下问题:
在编码时(尤其是在编码的早期),我经常不得不更改接口,直到一切都很好为止。
如果更改此类超类,则必须修改每个子类以实现该方法。
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
- 打开课程
- 类名称
- 使用
< Alt>
+< 1>
选择实施所有未初始化的方法
- Opening the class
- Clicking on the (errorous) class name
- ressing
<Alt>
+<1>
and selectingImplement all un-initialized methods
可以做很多次。
有没有一种方法可以选择所有相关的类,然后在IDE的某些魔术菜单上单击以在这些类中生成所有未实现的方法,如下所示:
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?
推荐答案
问题不是IDE不提供对此类操作的支持。但是您的编码方式需要改进。
The problem is not IDE that do not provide the support for such action. But the way your coding looks, that needs to improve.
您可以选择使用Java 8,在其中可以使用实现。
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.
这篇关于如何使用eclipse为接口/抽象类中的所有未实现方法生成方法存根?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!