java中接口的抽象方法是什么 [英] what is a abstract method on a interface in java
问题描述
可能的重复:
为什么要将 Java 接口方法声明为抽象方法?
我在我们的一个 ejb 接口中发现了以下代码.有谁知道抽象在接口中的作用?如果您这样做,还请解释为什么可能需要它或提供参考以阅读它=)
I found the following code in one of our ejb interfaces. Does anyone know what the abstract does in the interface? If you do please also explain why it might be needed or provide a reference to read about it =)
@Local
public interface IDomasOrderProcessor {
public abstract void executeOrderLines(List<OrderLine> lines);
public abstract void setupJob(List<OrderLine> lines);
public abstract void setupJob(OrderLine line);
}
推荐答案
abstract
在这种情况下是多余的.interface
上定义的所有方法都是 public
和 abstract
根据定义.
abstract
is redundant in this case. All methods defined on an interface
are public
and abstract
by definition.
接口体中的每个方法声明都是隐式的抽象,所以它的主体总是用分号表示,而不是阻止.
Every method declaration in the body of an interface is implicitly abstract, so its body is always represented by a semicolon, not a block.
接口体中的每个方法声明都是隐式的公开.
Every method declaration in the body of an interface is implicitly public.
这篇关于java中接口的抽象方法是什么的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!