java數字字串比較大小
阿新 • • 發佈:2019-01-25
String maxTotalValue = "0";
for (int i = 0; i < exeThreads.length; i++) {
String calResult = exeThreads[i].getResult();
if (calResult != null) {
// if (maxTotalValue.compareTo(calResult) < 0) {
// maxTotalValue = exeThreads[i].getResult();
// }
if (calResult.length() > maxTotalValue.length() && calResult.charAt(0) != '-') {
maxTotalValue = calResult;
} else if (calResult.length() == maxTotalValue.length()) {
if (calResult.compareTo(maxTotalValue) > 0) {
maxTotalValue = calResult;
}
}
// System.out.println("result:" + exeThreads[i].getResult());
}
}
for (int i = 0; i < exeThreads.length; i++) {
String calResult = exeThreads[i].getResult();
if (calResult != null) {
// if (maxTotalValue.compareTo(calResult) < 0) {
// maxTotalValue = exeThreads[i].getResult();
// }
if (calResult.length() > maxTotalValue.length() && calResult.charAt(0) != '-') {
maxTotalValue = calResult;
} else if (calResult.length() == maxTotalValue.length()) {
if (calResult.compareTo(maxTotalValue) > 0) {
maxTotalValue = calResult;
}
}
// System.out.println("result:" + exeThreads[i].getResult());
}
}