1 Comment

  1. Pavel Molchanov

    Same code can be written in a simpler way. Java has Consumer interface for this purpose.

    It will look like:

    Consumer test = (s) -> System.out.println(s);
    test.accept(“Hello World”);

    And full class may look like:

    package test;

    import java.util.function.Consumer;

    public class Test {

    public static void main(String[] args) {
    Consumer test = (s) -> System.out.println(s);
    test.accept(“Hello World”);
    }

    }

    Reply

Leave a Reply.. code can be added in <code> </code> tags