Commit 3c3a68fd by 杨林龙

1.9.0 仲利车辆列表增加最后定位时间字段-- 优化空指针判断逻辑

1 parent 01b3cdc5
......@@ -3,7 +3,10 @@ package cn.com.glsx.test;
import lombok.extern.slf4j.Slf4j;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import java.util.Optional;
import java.util.function.Consumer;
import java.util.stream.Collectors;
/**
......@@ -24,19 +27,14 @@ public class MainTest {
// Creating a list of Even Numbers
List<Integer> EvenNumbers = Arrays.asList(2, 4, 6, 8);
List<List<Integer>> listOfListofInts =
Arrays.asList(PrimeNumbers, OddNumbers, EvenNumbers);
List<List<Integer>> listOfListofInts = Arrays.asList(PrimeNumbers, OddNumbers, EvenNumbers);
System.out.println("The Structure before flattening is : " +
listOfListofInts);
System.out.println("The Structure before flattening is : " + listOfListofInts);
// Using flatMap for transformating and flattening.
List<Integer> listofInts = listOfListofInts.stream()
.flatMap(list -> list.stream())
.collect(Collectors.toList());
System.out.println("The Structure after flattening is : " +
listofInts);
List<Integer> listofInts = listOfListofInts.stream().flatMap(Collection::stream).collect(Collectors.toList());
Optional.of(listofInts).ifPresent(System.out::println);
// System.out.println("The Structure after flattening is : " + listofInts);
}
}
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!