Consumer interface in Java

A Consumer is a functional interface that accepts a single input and returns no output. There are also functional variants of the Consumer:  DoubleConsumer, IntConsumer, and LongConsumer. These variants accept primitive values as arguments. 
```
import java.util.function.Consumer;
import java.util.stream.Stream;

public class Main {
    public static void main(String[] args) {
        Consumer<String> printer = t -> System.out.println(t);
        Stream<String> s = Stream.of("a", "b", "c");
        s.forEach(printer);
    }
}
```
Consumer interface has two methods:
Method | Meaning
----- | -----
void accept(T t); | the single abstract method (SAM) which accepts a single argument of type T. 
default Consumer<T> andThen(Consumer<? super T> after); | a default method used for composition.

```
import java.util.Arrays;
import java.util.List;
import java.util.function.Consumer;

public class Main {
    public static void main(String[] args) {
        List<String> s = Arrays.asList("a", "b", "c", "d");

        Consumer<List<String>> c1=list->{
            for (int i = 0; i < list.size(); i++) {
                list.set(i, list.get(i).toUpperCase());
            }
        };
        Consumer<List<String>> c2=list-> list.stream().forEach(System.out::println);
        c1.andThen(c2).accept(s);
    }
}
```
BiConsumer is the most exciting variant of the Consumer interface. The consumer interface takes only one argument, but on the other side, the BiConsumer interface takes two arguments. Both, Consumer and BiConsumer have no return value. It also returns nothing just like the Consumer interface. It is used in iterating through the entries of the map.