I'm following this instruction :
Write a Java program to check if a string starts with a specified word. Go to the editor
Sample Data: string1 = "Hello how are you?"
Sample Output:
true
here is my code :
String string1 = "Hello how are you"; // intialize string String[] string2 = string1.split(" "); // split string into pieces System.out.println(string2[0]); // print Hello // if (string2[0] == "Hello") { // System.out.println("True"); // } System.out.println(string2[0] == "Hello"); // return false why? I was expecting a True
In the comments you can see my issue, I'm asking.