如题。该问题很简单,使用一个嵌套循环即可解决,代码如下所示:
/**
* 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;
}