+ 7
âŹAstro-GingyFlakeđčđ·
Use == cautiously as it isn't generally recommended for comparing string content, especially when dealing with string objects created using new String().
Prefer Equals() ( c# ) or equals() ( java) For accurate content comparison, always use the Equals() ( c# ) or equals() ( java) method. It ensures that the strings have the same characters in the same order, regardless of their memory location.
By understanding this distinction, you can write more reliable and efficient Java code with equals() and c sharp with Equals() involving string comparisons.
+ 5
âŹAstro-GingyFlakeđčđ·
Change the if to
if ((response.equals("hello"))||(response.equals("hi"))||(response.equals("hey"))) {
System.out.println("DumbAi: Hello!");