Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
Selected Reading
How to transform List string to upper case in Java?
Let’s first create a List string:
List<String> list = Arrays.asList("David", "Tom", "Ken","Yuvraj", "Gayle");
Now transform the above list to upper case:
list.stream().map(players -> players.toUpperCase())
To display, use forEach():
list.stream().map(players -> players.toUpperCase()) .forEach(players -> System.out.print(players + ""));
The following is an example to transform List string to upper case:
Example
import java.util.Arrays;
import java.util.List;
public class Demo {
public static void main(final String[] args) {
List<String> list = Arrays.asList("David", "Tom", "Ken","Yuvraj", "Gayle");
System.out.print("List = "+list);
System.out.print("\nUppercase strings = ");
list.stream().map(players -> players.toUpperCase()) .forEach(players -> System.out.print(players + ""));
}
}
Output
List = [David, Tom, Ken, Yuvraj, Gayle] Uppercase strings = DAVID TOM KEN YUVRAJ GAYLE
Advertisements
