jQuery in Action, 3rd edition
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
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "word compare" Watch "word compare" New topic

word compare

Leonard Stone

Joined: Nov 15, 2001
Posts: 1
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".
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.
SCJP for the Java� 2 Platform

So much trouble in the world -- Bob Marley
I agree. Here's the link: http://aspose.com/file-tools
subject: word compare
It's not a secret anymore!