Page 1 of 1
About Question enthuware.ocpjp.v8.2.1880 :
Posted: Thu Aug 25, 2016 6:34 am
by ramy6_1
Hello ,
What you mean by "Unlike most other functional interfaces, BiConsumer is expected to operate via side-effects." ?
Re: About Question enthuware.ocpjp.v8.2.1880 :
Posted: Thu Aug 25, 2016 8:25 am
by admin
This statement is from
https://docs.oracle.com/javase/8/docs/a ... sumer.html
Not sure whether you understand the meaning of the term "side effects". But basically, what it means is that it when you apply a BiConsumer on two arguments, it may modify the arguments themselves. Thus, applying the same BiConsumer on the same two arguments second time may produce a result that is different from the first time.
For example, if you have a BiConsumer that adds second argument to the first one like this:
bf = (a, b)-> a.append(b);
If you use this function on the same two arguments second time, the resulting value of a will be different.
Another term for this is "idempotent". Any function that is idempotent can be applied any number of times and the result will be the same as the first time. BiConsumer is not supposed to be idempotent, as per the documentation.
HTH,
Paul.
Re: About Question enthuware.ocpjp.v8.2.1880 :
Posted: Fri Apr 14, 2017 4:18 pm
by nikitos
Small mistake in explanation:
Predicate<T> has: boolean test(T t);
In explanation written Object instead of T. If we use withour generic - you are true:)
The same for Function<T,R>
Same for BiFunction and BiConsumer.
Or some another mean there?