• Post Reply Bookmark Topic Watch Topic
  • New Topic

How to figure out the Super type of a class being initialized.  RSS feed

 
Anooj Narvekar
Greenhorn
Posts: 10
IntelliJ IDE Java Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator



I need to figure out what is the Super type of list(in this case its List). Calling getSuperClass returns AbstractList.

PS: sorry if my subject is not appropriate.
 
Paul Clapham
Sheriff
Posts: 22819
43
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Okay. So the superclass of ArrayList is AbstractList. This is a correct statement. So what exactly is your question?
 
Greg Charles
Sheriff
Posts: 3015
12
Firefox Browser IntelliJ IDE Java Mac Ruby
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
getSuperclass() is a method on Class, and just gives you the immediate parent class of the class you call it on. You can then call it again on the returned superclass, and keep going until you reach java.lang.Object, the root class of every class in Java. However, you'll never get to List, because it's an interface. You can call list.getClass().getInterfaces() though, and List will be in the array of interfaces returned.
 
Greg Brannon
Bartender
Posts: 563
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If I were looking for the answer to your question, I would refer to the class' API page to get the class' lineage. Learn the usefulness of the API, and you'll be able to answer these type of questions on your own and help others answer them.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!