Currently, I see no differences in the following Java 8 lambda expressions:
Parameter Types :
Arrays.sort(strArray, (String s1, String s2) -> s2.length() - s1.length());
Types of parameters omitted :
Arrays.sort(strArray, (s1, s2) -> s2.length() - s1.length());
EDIT: In general, what are the pros and cons for specifying parameter types in Java 8 lambda expressions? And when do you need to specify?
I was thinking of several possible reasons (but I'm sure there are more):
- additional security checks when specified
- improved code readability
source
share