java - 获取每个数组列表中的最小值
问题描述
我正在做一个对成绩进行排序的程序。它比较了arrayslist的3个arraylist,我试图在1中获得最小的节点,在2中获得中等节点,在3中获得更大的节点。然后将其保存到1、2或3级。
以下代码不断重复节点。有人知道为什么吗?有什么建议么?
ArrayList<ArrayList<Double>> y = new ArrayList<ArrayList<Double>>(); // ->have 10 nodes in them of 10 elements each
ArrayList<ArrayList<Double>> y2 = new ArrayList<ArrayList<Double>>(); // ->have 10 nodes in them of 10 elements each
ArrayList<ArrayList<Double>> y3 = new ArrayList<ArrayList<Double>>(); // ->have 10 nodes in them of 10 elements each
for (int j = 0; j < y.size(); j++) {
for (int k = 0; k < y.get(j).size(); k++) {
if (y.get(j).get(k) < y2.get(j).get(k) && y.get(j).get(k) < y3.get(j).get(k)) {
grades.get(j).remove(14);
grades.get(j).add(14, 1.00);
grades2.add(grades.get(j));
}
if (y2.get(j).get(k) < y3.get(j).get(k)) {
grades.get(j).remove(14);
grades.get(j).add(14, 2.00);
grades2.add(grades.get(j));
} else {
grades.get(j).remove(14);
grades.get(j).add(14, 3.00);
grades3.add(grades.get(j));
}
}
}
解决方案
推荐阅读
- postgresql - 如何提高 json_agg 和 json_build_object 的性能?
- c# - C# FileInfo - 此 LINQ 查询中的附加条件
- antlr4 - ANTLR 4 错误 50 - 不匹配的字符 'i' 期望 '{'
- azure - Azure ARM 模板:功能限制,如何检测?
- bash - 从单个单元中运行在服务器上的所有 Java 进程中捕获 XMX 值
- reactjs - 无法从 vscode 部署到 heroku react 应用程序
- spring - Spring data JPA - 如何使用投影和/或命名查询返回嵌套映射的 id?
- batch-file - PSEXEC - 不被识别为内部或外部命令
- go - 试图理解 Go 中的“同步”。为什么这行得通?
- image - cloudinary img 格式打破了谷歌页面速度移动