문자열 배열이 있으므로 정렬되지 않으며 중복 요소가 있습니다. 별개의 요소를 계산하고 싶지만, 내 메서드를 호출하면 별개의 요소가 아니라 모든 요소의 수를 반환합니다. 제발, 제발요.정렬되지 않은 문자열 배열의 고유 요소 찾기
public static double countDistinctString(String[] array) {
double distinctStrings = 0;
for (int j = 0; j < array.length; j++){
String thisString = array[j];
boolean seenThisStringBefore = false;
for (int i = 0; i < j; i++){
if (thisString == array[i]){
seenThisStringBefore = true;
}
}
if (!seenThisStringBefore){
distinctStrings++;
}
}
return distinctStrings;
}
}
덕분에 너무 많은, 문제가 해결
: – Najme