我在 Java 中有以下接口(interface)
public interface IFoo
{
public abstract void foo();
public void bar();
}
foo() 和 bar() 有什么区别? 什么时候应该使用摘要?
两者似乎都能实现我想要的,除非我遗漏了一些微妙的东西?
更新 Why would one declare a Java interface method as abstract? 的副本
最佳答案
没有任何功能差异。 Java 接口(interface)中从未提供任何实现,因此所有方法声明都是隐式抽象的。
参见[1]:http://java.sun.com/docs/books/tutorial/java/IandI/abstract.html
上面的直接引用:
Note: All of the methods in an interface (see the Interfaces section) are implicitly abstract, so the abstract modifier is not used with interface methods (it could be—it's just not necessary).
关于java - 在 Java 中,什么时候应该在接口(interface)中使用抽象方法?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1492359/