aspose file tools*
The moose likes Beginning Java and the fly likes word compare Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "word compare" Watch "word compare" New topic
Author

word compare

Leonard Stone
Greenhorn

Joined: Nov 15, 2001
Posts: 1
Hi,
Could anyone help me with this:
I've to store to lists of words from a text file - about 200 in each file. wordlist1(sorted) is stored in an array, wordlist2(unsorted) is read in a word at a time. I'm using a binary search to find a match for a word (searching thru wordlist1 with a word from wordlist2).
If the wordlist2 word starts with a lowercase character and the wordlist1 word starts with a lowercase letter, the word must be printed to the screen with "YES", if the wordlist2 word starts with uppercase, wordlist1 word can be lower or upper and then printed to the screen with a "YES".
and
if the wordlist2 word starts with a lower and the wordlist1 starts with an uppercase,
print the word with "NO".
How do i check the word once i've found it? All the code has to be done without using any java utils.
I would greatly appreciate a coded example, because i've had loads of trouble with the comparing part.
Thanking you in advance.
Bosun Bello
Ranch Hand

Joined: Nov 06, 2000
Posts: 1510
the String class has these methods that you can use. toLowerCase()/toUpperCase(), startsWith(), equals().
Convert the word to lower or upper case while using equals to do the comparison, then use startsWith to determine what each word starts with.
------------------
Bosun
SCJP for the Java� 2 Platform


Bosun (SCJP, SCWCD)
So much trouble in the world -- Bob Marley
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: word compare