Which one of the following functional interfaces can you assign the method reference Integer::parseInt?
The static method parseInt()
in Integer class takes a String and returns an int, as in:
int parseInt(String s).
C.
the parseInt()
method takes a String and returns a value, hence we need to use the Function interface because it matches the signature of the abstract method R apply(T t).
In Function<T, R>, the first type argument is the argument type and the second one is the return type.
Given that parseInt takes a String as the argument and returns an int (that can be wrapped in an Integer), we can assign it to Function<String, Integer>.