那位JAVA高手帮我看看怎么作

来源:百度知道 编辑:UC知道 时间:2024/05/13 10:03:33
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;

public class SampleDatas {

public static String getDatasForEncode() {
return "Hello, I'm a String.";
}

public static Set getDatasForSort() {
Set set = new HashSet();
set.add("A");
set.add("B");
set.add("C");
set.add("D");
set.add("E");
set.add("F");
return set;
}

public static Map getDatasForScore() {
Map map = new HashMap();
map.put("A", "100");
map.put("B", "65");
map.put("C", "78");
map.put("D", "96");
map.put("E", "47");
map.put("F", "90");
map.put("G", "82");
map.put("H"

public static void main(String[] args) {
Object stu[] = SampleDatas.getDatasForSort().toArray();
Map scoreMap = SampleDatas.getDatasForScore();
ArrayList perfectList = new ArrayList();
ArrayList greatList = new ArrayList();
ArrayList goodList = new ArrayList();
ArrayList noPassList = new ArrayList();
for (int i = 0; i < stu.length; i++) {
String student = (String) stu[i];
int score = Integer.parseInt((String) scoreMap.get(student));
if (score == 100) {
perfectList.add(student);
} else if (score >= 80) {
greatList.add(student);
} else if (score >= 60) {
goodList.add(student);
} else {
noPassList.add(student);
}
}
//序列化
Collections.sort(perfectList);
Collections.sort(greatList);
Collections.sort(goodList);
Collections.sort(noPassList);
System.out.println("prefect:"+perfectList.toSt