Both strings appear to be the same when printed to the console, but not when compared using "=="
What am i doing wrong here?
String message = "Rejected | Ref ID: CaptureMe | Name:";
Pattern pattern = Pattern.compile("\\bRef ID:\\s+(\\S+)");
Matcher matcher = pattern.matcher(message);
String matchedRef = matcher.group(1);
System.out.print(matchedRef);
Prints: CaptureMe
String myRef = "CaptureMe";
if(matchedRef == myRef){
System.out.print(true);
}
else{
System.out.print(false);
}
Prints: FALSE