If by "compare" you mean check equality, you can just do string1 == string2
which gives you true
if the strings are equal.
If you need a comparison usable for alphabetic sorting, you can also do string1 < string2
, which returns true
if string1
comes before string2
.