- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
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));
- Related Articles
- Is an array a primitive type or an object in Java?
- Is array a primitive data type in Java?
- Is String a primitive data type or an object in Java?
- Get the name of a primitive type in Java
- List the Interfaces that an Interface Extends in Java
- How to empty an array in Java
- Convert double primitive type to a Double object in Java
- What would getPackage() return for a primitive or array in unnamed package in Java?
- What is the preferred method to check for an empty array in NumPy?
- Passing primitive values while instantiating a parameterized type (generic) in Java?
- Convert short primitive type to Short object in Java
- Convert byte primitive type to Byte object in Java
- How to convert an array of objects to an array of their primitive types in java?
- Can we create an object for an interface in java?
- Java Program to convert a Primitive Type Value to a String

Advertisements