You can get
the interfaces implemented by this class using getInterfaces() method
of java.lang.Class.
import java.util.*; public class GetImplementedInterfaces { public static void main(String args[]){ HashSet<Integer> mySet = new HashSet<>(); Class[] interfaces = mySet.getClass().getInterfaces(); System.out.println("Interfaces implemented by HashSet are"); for(Class c : interfaces) System.out.println(c.getName()); } }
Output
Interfaces implemented by HashSet are java.util.Set java.lang.Cloneable java.io.Serializable
No comments:
Post a Comment