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 Organizing Data Interfaces

exactly what is a implementation compare ? also @override ?

hello. just need more detail to understand those ? thx guys

2 Answers

Comparator<Type> is a Java interface, interfaces are basically a way of exposing some of the functionality of one class to another without you having to worry about all the implementation details.

But, because the Comparator interface already has it's own version of the method compare() and you want to make a customized version of that method for your own class, you use an annotation that tells the java compiler "nevermind that version of the method, use mine."

That's where the @Override annotation comes in.

Thank you so much for that answer. I thought we were overriding because it was necessary to override to use the method. But we're overriding to manipulate the method how we want.