Why – in Java 1.8 – use functions instead of functions?
The order seems strange because in regular Java, the return type is always specified first For example:
public static double sum(Iterable<Number> nums) { ... }
So why can you choose to specify them in the opposite way in the function and bifunction classes? For example:
interface Function<T,R> interface BiFunction<T,U,R>
I'm not asking for a better opinion here, but specifically:
a) Is there any technical or other (non style) benefit in prioritizing one order over another? Or is it a random choice?
b) Does anyone know the reasons for any statement in any document description or authoritative source, and why choose another one?
Narrator: this order seems even more strange if it extends to a higher city For example, a hypothetical quadfunction:
interface QuadFunction<A,B,C,D,R> { ... }
(at the time of writing, the highest power in the library is 2 – bifunction.)
See: http://download.java.net/jdk8/docs/api/java/util/function/package-summary.html
Solution
It is consistent with pre - existing symbols
The mathematical integer division function is extended to rational numbers:
(\): I x I -> Q
Functional programming version above (e.g. Haskell, Ocaml)
division :: Integer -> (Integer -> Rational) or division :: Integer -> Integer -> Rational
All three people said that "the partition function needs two integers and returns a rational number." In the functional example, it first describes your return C tells us "we return a rational number in the division function, which takes two integers" (ex float division (int a, int b) {})
In Java, the return type is on the left side of the method, Because Java wants to look like C. the designers of C think that "int main (int argv, char * argv [])" looks better than "main (int argv, char *)" argv []) int ". When writing code, at least for me, I often know what method will return before I know what it needs. (edit 1: we wrote something like string s = removespaces (textline) Such a line, so the return on the left matches the variable on the left)
In C #, func looks the same as Java 8 function