• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

word compare

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 1514
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
reply
    Bookmark Topic Watch Topic
  • New Topic