public class SampleEquals {
static void equalsshow(String str1, String str2) {
if (str1.equals(str2)) {
System.out.println('"' + str1 + '"' + " and " + '"' + str2 + '"' + " are the same");
}
else {
System.out.println('"' + str1 + '"' + " and " + '"' + str2 + '"' + " are not the same");
}
}
public static void main(String[] args) {
String apple = "apple";
String banana = "banana";
equalsshow(apple, banana);
}
}
결과
"apple" and "banana" are not the same