java中接口的抽象方法是什么 [英] what is a abstract method on a interface in java

查看:32
本文介绍了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 上定义的所有方法都是 publicabstract 根据定义.

abstract is redundant in this case. All methods defined on an interface are public and abstract by definition.

摘录 Java 语言规范第 9.4 节

接口体中的每个方法声明都是隐式的抽象,所以它的主体总是用分号表示,而不是阻止.

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆