Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
Selected Reading
Prove that the interface for a primitive type is an empty array in Java
The getInterfaces() method is used to prove that the interface for a primitive type is an empty array. A program that demonstrates this is given as follows −
Example
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));
}
}
Output
The Interface is: []
Now let us understand the above program.
The int.class is a reference to the Class object for the primitive type int. The interface for this is determined using the getInterfaces() method. This is an empty array as is obvious when it is displayed. A code snippet which demonstrates this is as follows −
Class c = int.class;
Class[] interfaces = c.getInterfaces();
System.out.println("The Interface is: " + Arrays.asList(interfaces));
Advertisements
