我知道这是一个奇怪的问题,但出于研究目的,有人可以告诉我编写这行代码的不同方式吗? 我正在“forEach(s ->ignoreWords.add(s.toUpperCase()));”中制作文字云。是我想更改的代码行。最好不是 lambda
提前非常感谢!!!!
研究了很多页面
BufferedReader br = new BufferedReader(new InputStreamReader(input));
ignoreWords = new HashSet<String>();
Stream<String> stream = Files.lines(Paths.get("/ignorewords.txt"));
stream.forEach(s -> ignoreWords.add(s.toUpperCase()));
最佳答案
这行得通吗?
Set<String> ignoreWords = Files.lines(Paths.get("/ignorewords.txt"))
.map(String::toUpperCase)
.collect(Collectors.toSet())
关于java - 有人可以告诉我这行代码的不同编写方式吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55736740/