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
Justin W946 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?