question about string
i know strings are immutable which means once constructed they cannot be changed. So i thought to write a program to replace a word in a string with another word specified. here is my program
publicclass ReplacingString{
publicstaticvoid main(String[] args){
replaceWord("To be or not to be, that is the question","be","see");
}
staticvoid replaceWord(String doc, String target, String replace){
//StringBuffer document = new StringBuffer(doc);
String word = doc.replaceAll(target, replace);
System.out.println(word);
}
}
Simple and easy. but i had to create another String word and then print it out though it does not matter to me at all but was curious if i can do the same thing with StringBuffer? i saw the api docs, they have only replace method not replaceAll. is there any way i can write the same program with StringBuffer?

