Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Java Java Data Structures - Retired Exploring the Java Collection Framework Lists

Miguel Gonzalez Rocha
Miguel Gonzalez Rocha
2,849 Points

What are interfaces and superinterfaces?

He made a new List, arraylist and after that i got confused because i investigated "Collections" and it says it is a superinterface (List belongs to Collection), then how could he use it without making it in the first place? or you dont need to "make" a new Collection because it is a Superinterface, and is like using String which everyone has access to it?

1 Answer

Allan Clark
Allan Clark
10,810 Points

An interface is like a guarantee that your class will implement certain methods. ArrayList extends the List interface, this just means that an ArrayList will have all the methods that are required to be a List. In the real world if you think the Door concept as being an interface, you know anything that "extends" door (i.e. front door, car door, doggie door) will work a certain way.

Superinterface is not a separate entity, it refers to the hierarchy. When an interface is extended or implemented it becomes a Superinterface of what extended/implemented it. If class C implements interface B, and interface B extends interface A, then A is a Superinterface to B and . Also B is a Superinterface for C.

      interface A  (Superinterface to B and C)
             |
      interface B (Superinterface to C) 
             |
      class C

*side note interface B is a Subinterface to interface A.

Collection refers a group of specific classes and interfaces that hold "collections" of objects. For example ArrayList class and Set interface are a part of Java Collections Framework (JCF) often referred to as just "collections."

Hope this helps!

Miguel Gonzalez Rocha
Miguel Gonzalez Rocha
2,849 Points

Thank you very much for the response, i undertand now with that example and the use of the word hierarchy makes perfect sense