Go Back   Computer Forums > General Computing > Programming
Click Here to Login
Join Computer forums Today


Reply
 
Thread Tools Search this Thread Display Modes
 
Old 05-08-2008, 12:34 AM   #1
In Runtime
 
Join Date: Jul 2005
Posts: 192
Default Java Help: String comparison

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.
__________________

__________________
Core 2 Duo E8400 | GeForce 8800gt | 2gb Mushkin RAM | Intel P35 mobo | Seagate 120gb 7200rpm | Thermaltake W0093RU 500W | Samsung 22" widescreen | Raidmax Ninja Case |
kocheez75 is offline   Reply With Quote
Old 05-08-2008, 06:47 AM   #2
In Runtime
 
Join Date: Apr 2008
Posts: 230
Default Re: Java Help: String comparison

You'd have to use a regular expression to remove the whitespace and then compare them.

str = str.replace('regex');
silent1mezzo is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off



All times are GMT -5. The time now is 07:52 AM.


Powered by vBulletin® Version 3.8.8 Beta 4
Copyright ©2000 - 2017, vBulletin Solutions, Inc.
Search Engine Friendly URLs by vBSEO 3.6.0