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.


Justin W
Justin W
946 Points

How interfaces work and how they are used. Clarification help.

I understand that interfaces create methods that can be used in other classes, but it is up to the class that uses it to tell it how the interface's method actually works. So, I think that, when something "implements" an interface, it simply says that this new class uses the method names of the interface and possibly the same arguments. I can't figure out why you would implement an interface like the video does by overriding the compareTo() method instead of just creating a fully implemented method, unless it is simply to prevent runtime errors if for some reason another class tries to use the objects method, in this case the Treet.compareTo() method, to compare it to something that is not a Treet. Is this the use for interfaces and implementation to prevent inadvertent runtime errors and instead catch them when compiling?