证明一个原始类型的接口在 Java 中是空数组
getInterfaces() 方法用于证明一个原始类型的接口是空数组。以下程序演示了这一点 −
示例
package Test;
import java.util.*;
public class Demo {
public static void main(String[] args) {
Class c = int.class;
Class[] interfaces = c.getInterfaces();
System.out.println("The Interface is: " + Arrays.asList(interfaces));
}
}输出
The Interface is: []
现在让我们来理解一下上面的程序。
int.class 是对原始类型 int 的 Class 对象的引用。此对象的接口由 getInterfaces() 方法确定。当显示时,可以看到这是一个空数组。以下代码片段演示了这一点 −
Class c = int.class;
Class[] interfaces = c.getInterfaces();
System.out.println("The Interface is: " + Arrays.asList(interfaces));广告
数据结构
网络
关系数据库管理系统
操作系统
Java
iOS
HTML
CSS
Android
Python
C 编程
C++
C#
MongoDB
MySQL
Javascript
PHP