I am asking whether I can take a function as key for a map.
Normally, a key object for a map should have hashcode
and equal
methods. However, Java Function
is a method object, and it does not have these two methods.
Function<String, String> quote1 = s -> "'" + s + "'";
Function<String, String> quote2 = s -> "'" + s + "'";
System.out.println(quote1.equals(quote2)); //false
so is it possible? If possible, any sample? I did not get this case by google.
If not, is there any other way to identify time-consuming Function
execution result?
Thanks