Java 8 Cosumer Functional Inteface.
Java 8 offers a Functional interface called Consumer,A consumer allows you to take in a value and return no results.It is expected to have side effects.
1
2
3
4
5
6
7
public class ConsumerExample {
public static void main(String[] args)
{
Arrays.asList("a","b","c","d").stream().forEach(testConsumer);
}
static Consumer<String> testConsumer=(x)->{System.out.println(x);};
}
More information can be found here https://docs.oracle.com/javase/8/docs/api/java/util/function/Consumer.html