Skip to content

使用接口抽取过滤器函数#204

Open
zdmhahaha wants to merge 1 commit intomasterfrom
zdmha
Open

使用接口抽取过滤器函数#204
zdmhahaha wants to merge 1 commit intomasterfrom
zdmha

Conversation

@zdmhahaha
Copy link
Copy Markdown
Contributor

  • 这个PR解答了当前仓库中的题目(机器人会自动判题并合并当前PR)
  • 这个PR修复了当前仓库中的一些代码缺陷(机器人不会判题,而是由管理员来处理当前PR)

@hcsp-bot
Copy link
Copy Markdown
Contributor

🎉 感谢提交Pull Request!请稍等片刻,我们已经将其提交到CI进行检查,一旦有结果会立即通知您!

@@ -1,14 +1,21 @@
package com.github.hcsp.polymorphism;

import com.sun.xml.internal.ws.api.model.wsdl.WSDLOutput;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

无用导入 - com.sun.xml.internal.ws.api.model.wsdl.WSDLOutput 。

import com.sun.xml.internal.ws.api.model.wsdl.WSDLOutput;

import java.util.ArrayList;
import java.util.Arrays;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

无用导入 - java.util.Arrays 。

return filter(users, new Predicate<User>() {
@Override
public boolean test(User user) {
return user.id % 2 == 0 ;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

';' 前不应有空格。

if (user.name.startsWith("王")) {
results.add(user);
// 过滤姓王的用户
public static List<User> filterWangUsers (List < User > users) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'<' 后不应有空格。
'<' 前不应有空格。
'>' 前不应有空格。

// 你可以发现,在上面三个函数中包含大量的重复代码。
// 请尝试通过Predicate接口将上述代码抽取成一个公用的过滤器函数
// 并简化上面三个函数
public static List<User> filter(List<User> users, Predicate<User> predicate){
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'{' 前应有空格。

@hcsp-bot
Copy link
Copy Markdown
Contributor

你的提交 cb71841 ,似乎失败了:Your tests failed on CircleCI

😅 请不要气馁,仔细分析原因,再接再厉!

@hcsp-bot hcsp-bot mentioned this pull request Oct 12, 2021
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants