Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

import java.util.function.Consumer;

public class Main {
    public static void main(String[] args) {
        Message message = new Message("java2s.com");

        Consumer<Message> messageConsumer = (t) -> System.out.println(t);
        Consumer<Message> endConsumer = (t) -> System.out.println("End: " + t);
        messageConsumer.andThen(endConsumer).accept((message));

    }

}

class Message {

    private String msg;

    public Message(String msg) {
        this.msg = msg;
    }

    public String getMessage() {
        return msg;
    }

    public String toString() {
        return getMessage();
    }
}