public static List getMinValueIndexes(List bigDecimals) { List indexes = new ArrayList<>(); BigDecimal minValue = bigDecimals.get(0); for (int i = 1; i < bigDecimals.size(); i++) { BigDecimal current = bigDecimals.get(i); int comparison = current.compareTo(minValue); if (comparison < 0) { minValue = current; indexes.clear(); } else if (comparison == 0) { indexes.add(i); } } return indexes; }

Java代码优化:获取BigDecimal列表中最小值所有索引

原文地址: https://www.cveoy.top/t/topic/qaGG 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录