简体   繁体   English

有人可以告诉我另一种编写此代码行的方式吗?

[英]Can someone tell me a different way of writing this line of code?

I know this is a strange question but for research purposes could anyone tell me a different way of writing this line of code? 我知道这是一个奇怪的问题,但是出于研究目的,有人可以告诉我另一种编写此代码行的方式吗? I am making a word cloud in The "forEach(s -> ignoreWords.add(s.toUpperCase()));" 我在“ forEach(s-> ignoreWords.add(s.toUpperCase()));”中制作词云 is the line of code I would like to change. 是我要更改的代码行。 Preferably not a lambda 最好不是lambda

Thanks very much in advance!!!! 首先十分感谢!!!!

Researched numerous pages 研究了无数页

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()));

Will this work? 这样行吗?

Set<String> ignoreWords = Files.lines(Paths.get("/ignorewords.txt"))
                               .map(String::toUpperCase)
                               .collect(Collectors.toSet())

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 有人可以告诉我代码中的错误吗? - Can someone tell me the error in my code? 有人可以在这里更正我的代码吗? 另外,有人可以告诉我在 Java 中定义函数的正确方法吗? - Can someone correct my code over here? Also, can someone tell me the proper way to define a function in Java? 有人能告诉我这段代码(Java)发生了什么吗? - Can someone tell me what is happening in this code (Java)? 有人可以看看我的代码并告诉我出了什么问题吗? - Can someone look at my code and tell me whats wrong? 有人可以帮助我编写我正在编写的代码吗? (爪哇) - Can someone please help me with the code I am writing? (Java) 有人可以帮我翻译 java 中的这行代码吗? - Can someone help me to translate this line of code in java? 复制数组并更改值? 有人能告诉我我的代码有什么问题吗 - Copying an array and changing the values? Can someone tell me what is wrong with my code 有人可以告诉我为什么我的《生活游戏》代码无法正常工作吗? - Can someone please tell me why my Game of Life code wont work? 有人可以帮我写正则表达式吗? - Can someone help me with writing a regular expression? 谁能告诉我为什么这个if语句总是给我假的? - can someone tell me why this if statement always give me false?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM