I want to ask a question.
I feel so confused about my own coding because i think it is correct.
This is the issue.
public static void main(String[] args) {
String x = "Robert : Hi There";
String y = "Robert";
System.out.println(x.substring(0, x.indexOf(":")).trim());
if(x.substring(0, x.indexOf(":")).trim() != y){
System.out.println("Pass");
}
else
{
System.out.println("Not Pass");
}
}
This gave me output:
Robert
Pass
I want the output is "Not Pass" but why did my coding gave another result.
I hope you can tell what is wrong.
Thank You.