Condition statements doesn't work
Help master, i can't figure it out how to solve this. Here's my code : ... import java.util.Scanner; public class Program { public static void main(String[] args) { Scanner input = new Scanner(System.in); String x = input.nextLine(); String[] s = x.split(" "); int l = s.length; for (int i=0; i<l; i++) { String y = s[i]; //When i print y here, it shows y is the input in example : A if (y=="A") { s[i] = "Apple"; } else if (y=="B") { s[i] = "Banana"; } else { s[i] = "Fruit"; } } String o = String.join(" ",s); System.out.print(o); } } no matter what the input it's always be result : Fruit Fruit Fruit ..... In example : A B Output : Fruit Fruit i tried manually put y = "A" in the code to run the if-statements, it's work and give output "Apple"