I split String to String[] arr and want to compare element of arr with String but I don't know why System.out.println(arr[0] == "P"); return 'false'
Please check my code and answer to me. Thank you!
enter code here
String s = "pPooyy";
s = s.toUpperCase();
String[] arr;
arr = s.split("");
System.out.println(arr[0]);
System.out.println(arr[0] == "P");
this is result. P false
System.out.println(arr[0]); -> the result of this println is P so I thought System.out.println(arr[0] == "P"); would return 'true' but it wasn't.
Why are these two types different?