判断 对象是否为空

    1. Optional.ofNullable(queueWhiteOne).isPresent())

    //防止对象空指针异常

    1. Optional.ofNullable(list).orElse(Lists.newArrayList());
    2. public static void main(String[] args) {
    3. List<String> list = null;
    4. List<String> newList = Optional.ofNullable(list).orElse(Lists.newArrayList());
    5. newList.forEach(x -> System.out.println(x));