Java Help: String comparison

kocheez75

In Runtime
Messages
192
I have two strings that contain the same letters, but not the same characters.

ex: string answer = E L E P H A N T
string word = ELEPHANT

Is there any way to tell if these are equal? I have a while loop that needs to exit when answer = word. Any help would be appreciated.
 
You'd have to use a regular expression to remove the whitespace and then compare them.

str = str.replace('regex');
 
Back
Top Bottom