Skip to content

将List处理成Map<String, List> - #201

Open
zdmhahaha wants to merge 5 commits into
masterfrom
zdmhahaha
Open

将List处理成Map<String, List>#201
zdmhahaha wants to merge 5 commits into
masterfrom
zdmhahaha

Conversation

@zdmhahaha

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

@hcsp-bot

Copy link
Copy Markdown
Contributor

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

@@ -1,8 +1,6 @@
package com.github.hcsp.collection;

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.

文件未以空行结尾。

import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.*;

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.* 。

//创建一个键值对
Map<String, List<User>> map = new HashMap<>();
// 遍历所有的部门,再遍历所有对象将是这个的对象加到这个部门
for (String Dname : departmentName) {

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.

名称 'Dname' 必须匹配表达式: '^[a-z][a-zA-Z0-9]*$' 。

}
}
Collections.sort(partlist, new sortage());
map.put(Dname,partlist);

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.

',' 后应有空格。

return map;
}

private static class sortage implements Comparator<User> {

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.

名称 'sortage' 必须匹配表达式: '^[A-Z一-鿿][a-zA-Z0-9一-鿿]*$' 。

private static class sortage implements Comparator<User> {
@Override
public int compare(User o1, User o2) {
if (o1.getAge() != o2.getAge()){

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.

'{' 前应有空格。

@Override
public int compare(User o1, User o2) {
if (o1.getAge() != o2.getAge()){
return (o1.getAge() - o2.getAge());

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.

return 值周围不必要的小括号。

@hcsp-bot

Copy link
Copy Markdown
Contributor

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

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

@hcsp-bot

Copy link
Copy Markdown
Contributor

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

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

@hcsp-bot

Copy link
Copy Markdown
Contributor

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

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

@hcsp-bot

Copy link
Copy Markdown
Contributor

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

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

@hcsp-bot

Copy link
Copy Markdown
Contributor

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

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

This was referenced Oct 25, 2021
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