The String API explains a wealth of methods that are at your disposal to accomplish what you need.
String (Java Platform SE 6)
Draw out your requirements and break the problem down....do you know...