Your second code snippet isn't correct. It should read like this:
Bart Boersma wrote:1) But what does it do behind the scene's?
Something like this:
I replaced the type variables
T and
U with
Squirrel and
String to make it more clear in the context of your question, but the real method implementation of course works with generics so that it doesn't just work for squirrels and strings.
2) What does the funcational interface Function (and apply method) do behind the scene's (I get that it order the String values specified in te getSpecies() method but how does it work?
It transforms the object that you want to compare, but the application doesn't know how to compare (
Squirrel) to an object that the application DOES know how to compare (
String).