This week's book giveaway is in the Design forum.
We're giving away four copies of Building Microservices and have Sam Newman on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes need help Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Building Microservices this week in the Design forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "need help" Watch "need help" New topic

need help

mandy fern

Joined: Aug 21, 2001
Posts: 12
How do I write a program to extract initials from a name which has the following format:[ Dr. ] First name second first name third first name... Surname. The output should be something like this R. W. D. F.!
James Gray
Ranch Hand

Joined: Sep 10, 2001
Posts: 30
How about using a java.util.StringTokenizer to break the name into seperate tokens, ignoring title tokens like the "Dr." in your example, and otherwise storing/printing the first character of each token?
mandy fern

Joined: Aug 21, 2001
Posts: 12
How do I print first character of each token?
William Barnes
Ranch Hand

Joined: Mar 16, 2001
Posts: 986

The "nextToken" method returns a String. So you will be printing the first character of a String (which I think you already know how to do).

Please ignore post, I have no idea what I am talking about.
Have you checked out Aspose?
subject: need help
It's not a secret anymore!