forked from pandeyprem/DSA-Java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStream_map_function.java
More file actions
31 lines (21 loc) · 851 Bytes
/
Stream_map_function.java
File metadata and controls
31 lines (21 loc) · 851 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
//Stream map(Function mapper) returns a stream consisting of the results of applying the given function to the elements of this stream.
//Stream map() function with operation of converting lowercase to uppercase.
import java.util.*;
import java.util.stream.Collectors;
class Solution {
/
public static void main(String[] args)
{
System.out.println("The stream after applying "
+ "the function is : ");
// Creating a list of Integers
List<String> list = Arrays.asList("ritu", "manav", "m", "g", "e", "h", "s", "a");
// Using Stream map(Function mapper) to
// convert the Strings in stream to
// UpperCase form
List<String> answer = list.stream().map(String::toUpperCase).
collect(Collectors.toList());
// displaying the new stream of UpperCase Strings
System.out.println(answer);
}
}