Let's say you have a custom class:
public class T {
int a;
int b;
}
Is there a way you can split up the class in a lambda expression in the following way:
(Stream of T instances).forEach((a, b) -> {});
Java doesn't have the concept of tuples, so no! But there can be a workaround by converting the stream to a Map (which has a lot of limitations and consequences):
(Stream of T instances)
.collect(Collectors.toMap(t -> t.a, t -> t.b))
.forEach((a, b) -> {});
Map even? and what limitations and consequences are related to OP's problem?BiConsumer rather than criticizing my post(as always).
stream.forEach(t -> {... t.a ... t.b ...});?