Go Back   Computer Forums > General Computing > Programming
Join Computer forums Today

Thread Tools Search this Thread Display Modes
Old 05-07-2008, 11:34 PM   #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, 05: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

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 12:26 PM.

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