package com.lovecoding.day24.function02;

import org.junit.Test;

import java.util.function.Consumer;
import java.util.function.Function;
import java.util.function.Supplier;

public class Test01 {

    @Test
    public void test03(){
        Function<Integer,String[] > function1 =  String[]::new;
        Function<Integer,String[] > function2 =  e -> new String[e];

        String[] apply = function1.apply(10);
        System.out.println(apply.length);
    }

    @Test
    public void test02(){

        Function<String, Person> function1 =  e -> new Person(e);
        //构造器
        Function<String, Person> function2 =  Person::new;

    }

    @Test
    public void test01(){

        //lambda
        Consumer<String>  consumer1 = e -> System.out.println(e);
        //对象引用
        Consumer<String>  consumer2 = System.out::println;

        // e -> System.out.println(e);
        // System.out::println;

        //类引用
        Supplier<Double> supplier1 = Math::random;
        Supplier<Double> supplier2 = () -> Math.random() ;

    }
}
