I need help writing code that converts a given name like into initials and surname. For example, if a name is Ricky James, it should do R James and if the name is Henry William James, that should become H W James.
I have written a method that converts Ricky James to R James and I have used StringTokenizer, but I need help if the name has 3 or more tokens, like the second one.
I know I can use StringTokenizer but I can't really make out how the logic works.
My try is pasted below:
Would really appreciate help with this.
Originally posted by Campbell Ritchie:
Go through the StringTokenizer API, where it says that it is deprecated, and you should use String.split() instead. String.split() returns a String array, which you may find easier to use.
minor spellling corrections[/edit]
[ May 06, 2007: Message edited by: Campbell Ritchie ]
Thanks for this tip Ritchie. I have solved the problem using StringTokenizer and have pasted the code of the method in the previous method. But as a next step I am gonna use String.split() to learn that.
Really appreciate you took time to reply to my post.