Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Java Java Data Structures 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