如何在Java中将List字符串转换为大写?
首先创建一个List字符串:
List<String> list = Arrays.asList("David", "Tom", "Ken","Yuvraj", "Gayle");现在将上面的列表转换为大写:
list.stream().map(players -> players.toUpperCase())
要显示,请使用forEach():
list.stream().map(players -> players.toUpperCase()) .forEach(players -> System.out.print(players + ""));
下面是将列表字符串转换为大写的示例:
示例
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 + ""));
}
}输出结果
List = [David, Tom, Ken, Yuvraj, Gayle] Uppercase strings = DAVID TOM KEN YUVRAJ GAYLE
热门推荐
10 祝孙辈生日祝福语简短
11 恋人跨年祝福语大全简短
12 考大学敬酒简短祝福语
13 开工投产大吉祝福语 简短
14 偶然结婚祝福语朋友简短
15 感谢学长学姐祝福语简短
16 戏精的祝福语简短
17 我要结婚祝福语简短
18 婚前女儿生日祝福语简短