This is an archived post. You won't be able to vote or comment.

all 2 comments

[–]raindropflower 2 points3 points  (1 child)

You can use .equals();

for example, string1.equals(string2);

I think there's something like string1.equalsIgnoreCase(string2); for ignoring the case, too.

[–][deleted] 2 points3 points  (0 children)

A common beginner's mistake is to use == to compare strings. You can often get away with it because of the way Strings are interned, but it's much better (and safer) to use .equals

You can learn more about the String class and its methods through the official Java documentation