Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History
48 lines (48 loc) · 1.47 KB

File metadata and controls

48 lines (48 loc) · 1.47 KB
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
//import org.junit.Test;
//import org.junit.runner.RunWith;
//import org.junit.runners.JUnit4;
//
//import java.util.Optional;
//import java.util.Set;
//import java.util.stream.Collectors;
//import java.util.stream.Stream;
//
//import static org.junit.Assert.assertEquals;
//
///**
// * @author xiang.wei
// * @create 2018/1/17 11:05
// */
//@RunWith(JUnit4.class)
//public class StreamTest {
// @Test
// public void testDropWhile() throws Exception {
// final long count = Stream.of(1, 2, 3, 4, 5)
// .dropWhile(i->i%2!=0)
// .count();
// assertEquals(4, count);
// }
//
// /**
// * 对于输入的 String 流 ,先通过 flatMapping 把 String 映射成 Integer 流 ,再把所有的 Integer 收集到一个集合中。
// */
// @Test
// public void testFlatMapping() {
// final Set<Integer> result=Stream.of("a","ab","abc")
// .collect(Collectors.flatMapping(v -> v.chars().boxed(),Collectors.toSet()));
// assertEquals(3,result.size());
// }
//
// /**
// * Optional 流中包含 3 个 元素,其中只有 2 个有值。在使用 flatMap 之后,结果流中包含了 2 个值。
// */
// @Test
// public void testStream() {
// final long count = Stream.of(
// Optional.of(1),
// Optional.empty(),
// Optional.of(2)
// ).flatMap(Optional::stream).count();
// assertEquals(2,count);
// }
//}
Morty Proxy This is a proxified and sanitized view of the page, visit original site.