No it is not the only way, but it is the easiest and it compares the contents of the string rather than if they are the same 'object' like an == operator would do.

Have a read through the String...