如題。該問題很簡(jiǎn)單少辣,使用一個(gè)嵌套循環(huán)即可解決好啰,代碼如下所示:
/**
* judge that a String Array whether or not contained equal String
*
* @param strings
* a string Array
* @return return true, contained; return false, not contained
*/
public static boolean judgeStrArrayContainsSameStr(String[] strings) {
int len = strings.length;
for (int i = 0; i < len; i++) {
String temp = strings[i];
for (int j = i + 1; j < len; j++) {
String string = strings[j];
if (string.equals(temp)) {
return true;
}
}
}
return false;
}