Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

need help

 
mandy fern
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How do I print first character of each token?
Thanks
 
William Barnes
Ranch Hand
Posts: 986
Eclipse IDE Firefox Browser Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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).
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic