尝试使用存储桶排序在java中按长度排序字符串数组,但我不断使数组索引超出范围
String[] bucketSort = new String[MAX_NAMES + 1];
for(int i = 0; i < numNames; i++) {
bucketSort[names[i].length()] += 1;
}
int outPos = 0;
for(int i = 0; i < bucketSort.length; i++) {
if(bucketSort[i].length() > 0) {
names[outPos++] = i;
}
}