forked from PacktPublishing/Java-Coding-Problems
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain.java
More file actions
32 lines (24 loc) · 905 Bytes
/
Copy pathMain.java
File metadata and controls
32 lines (24 loc) · 905 Bytes
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
package modern.challenge;
import java.util.stream.Stream;
public class Main {
public static void main(String[] args) {
String result1Map = Stream.of("hello")
.map(s -> s + " world")
.findFirst()
.get();
System.out.println(result1Map);
String result1 = "hello".transform(s -> s + " world");
System.out.println(result1);
String result2Map = Stream.of("gooool! ")
.map(String::toUpperCase)
.map(s -> s.repeat(2))
.map(s -> s.replaceAll("O", "OOOO"))
.findFirst()
.get();
System.out.println(result2Map);
String result2 = "gooool! ".transform(String::toUpperCase)
.transform(s -> s.repeat(2))
.transform(s -> s.replaceAll("O", "OOOO"));
System.out.println(result2);
}
}