[英]How can I reference a super method in a Java class that implements an interface but does not extend another class?
[英]How can I check one Interface is extend another Interface in java
接口 1 擴展接口 2
var = Interface1 // 在 var 中獲取 Interface1 的名稱。 if(Interface1 extends Interface2 ) // 如何測試這個條件。
假設你的意思是你有.class
對接口的引用,你可以使用isAssignableFrom
。
if (Interface2.class.isAssignableFrom(Interface1.class)) {
// Interface1 is a subtype of Interface2
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.