You can get
the super class of given class using 'getSuperclass' method of
java.lang.Class.
import java.util.*; public class GetSuperClass { public static void main(String args[]){ HashSet<Integer> mySet = new HashSet<> (); Class superClass = mySet.getClass().getSuperclass(); System.out.print("Super class of class HashSet is : "); System.out.println(superClass.getName()); } }
Output
Super class of class HashSet is : java.util.AbstractSet
No comments:
Post a Comment