小编pps*_*pps的帖子

Java 8删除重复的字符串,无论列表中的大小写如何

我们如何从String列表中删除重复元素而不考虑每个单词的大小写,例如考虑下面的代码片段

    String str = "Kobe Is is The the best player In in Basketball basketball game .";
    List<String> list = Arrays.asList(str.split("\\s"));
    list.stream().distinct().forEach(s -> System.out.print(s+" "));
Run Code Online (Sandbox Code Playgroud)

这仍然提供与下面相同的输出,这是显而易见的

Kobe Is is The the best player In in Basketball basketball game .
Run Code Online (Sandbox Code Playgroud)

我需要如下结果

Kobe Is The best player In Basketball game .
Run Code Online (Sandbox Code Playgroud)

java java-8

3
推荐指数
1
解决办法
1696
查看次数

标签 统计

java ×1

java-8 ×1