package com.lovecoding.day24.optional01;

import org.junit.Test;

import java.util.Optional;

public class Test01 {

    @Test
    public void test01(){

        String str = "hello";
        Optional<String> str1 = Optional.of(str);

        String s = str1.get();
        System.out.println(s);

        String str2 = null;

        Optional<String> str21 = Optional.ofNullable(str2);
        System.out.println(str21.orElseGet( () -> "1" ));

        String str3 = str21.orElse("java");
        System.out.println(str3);

    }
}
