File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes Creating an address book... Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Creating an address book..." Watch "Creating an address book..." New topic

Creating an address book...

Dan Silva
Ranch Hand

Joined: Sep 05, 2007
Posts: 86
I'm starting to create an address book, but am not aware of how to create a 'Search' field, like a normal gui address book. I am thinking that I should just check the first letter of the last name (which I'm not sure how to do either) and then just put each address in that particular unit (i.e. the Dan Silva would be in the 'S' class, and so on). If anyone can point me in the right direction for these, that would be great.
Stan James
(instanceof Sidekick)
Ranch Hand

Joined: Jan 29, 2003
Posts: 8791
The simplest search might require exact matches, just a String equals

String has some methods that might make things more fun. You might try

to find "il" in "Silva"

Probably next up the complexity ladder is regular expressions. If you've never used them, this might be a good excuse to learn. See the JavaDoc for Pattern and Google for "Sun tutorial regular expressions" to find more how-to.

For a journey into some pretty cool objects and algorithms, a Ternary Search Tree is a great way to do "autocomplete" things, so typing "S" might suggest "Silva" and "Smith" and "Si" would narrow down to just "Silva".

Think about doing all your compares on lower-cased strings to help your chances.

Any of those match your current skills & comfort?

A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
I agree. Here's the link:
subject: Creating an address book...
jQuery in Action, 3rd edition