在Android中,比较多个字符串可以使用以下几种方法:
String str1 = "Hello";
String str2 = "World";
String str3 = "Android";
if (str1.equals(str2) && str2.equals(str3)) {
// 字符串相等
} else {
// 字符串不相等
}
String str1 = "Hello";
String str2 = "World";
String str3 = "Android";
if (str1.compareTo(str2) == 0 && str2.compareTo(str3) == 0) {
// 字符串相等
} else {
// 字符串不相等
}
String[] strArray1 = {"Hello", "World", "Android"};
String[] strArray2 = {"Hello", "World", "Android"};
if (Arrays.equals(strArray1, strArray2)) {
// 字符串数组相等
} else {
// 字符串数组不相等
}
以上方法可以根据具体需求选择适合的方式进行字符串比较。