I need to understand which class and method in Java I should use to replace every, for example, 3d letter in any sentence.
For example, in this sentence: "This period was good" I want to replace every 3 d letter... with "r" exactly.... so at the end of compilation I should have
"Thrs perior war gord"
And if the letter in this sentense consists from only one letter- there is no changing.
Since the sentence is contained in a String, start by looking at the String class. Also the StringBuilder and StringBuffer classes would be useful.
See the API doc: http://docs.oracle.com/javase/8/docs/api/index.html
Welcome again
Did you really say to replace every 3rd letter in a sequence, or did you mean in a String? Did you know there is a class specifically designed for altering Strings? It even has a method for replacing characters. That would be another possible solution.
Campbell Ritchie wrote:Welcome again
Did you really say to replace every 3rd letter in a sequence, or did you mean in a String? Did you know there is a class specifically designed for altering Strings? It even has a method for replacing characters. That would be another possible solution.
Antonio,Good job!
please use code tag,it will make your code look better and readable to others.their are lot of features on ranch for posting,so utilize them.
Thanks,
kind regards,
Praveen.
Try to enjoy your work while doing it,it will Automatically convert in Hard Work...
The sample results: "Thrs perior war gord" showed some replacements but I'm not sure what rules were used.
For me replacing every third letter in:
would replace the letters above the 3s shown above. If the spaces are not considered letters.