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[] argv) {
        Util util = new Util();

        Consumer<String> consumer = str -> util.print(str);
        consumer.accept("Hello");

        Consumer<String> consumer1 = util::print;
        consumer1.accept("java2s.com");

        util.debug();
    }
}

class Util {
    private int count = 0;

    public void print(String s) {
        System.out.println(s);
        count++;
    }

    public void debug() {
        System.out.println("count:" + count);
    }
}