我们常常遇到abstract class与 interface的区别,今天却遇到了abstract interface,感觉interface不用abstract再修饰了啊。结论:事实也确实如此,编译为.class文件后abstract interface成为了interface。
package com.abstractinterface; public abstract interface DaemonUserSignal { public abstract void signal(); }
package com.abstractinterface; public interface DaemonUserSignal2 { public abstract void signal(); }
编程后结果比较:
D:\git\concurrent_crypto\target\classes\com\abstractinterface>javap DaemonUserSignal.class Compiled from "DaemonUserSignal.java" public interface com.abstractinterface.DaemonUserSignal { public abstract void signal(); } D:\git\concurrent_crypto\target\classes\com\abstractinterface>javap DaemonUserSignal2.class Compiled from "DaemonUserSignal2.java" public interface com.abstractinterface.DaemonUserSignal2 { public abstract void signal(); }