Use character wrapper to code a replace a letter in a string with a new letter keeping the original case

前端 未结 3 801
没有蜡笔的小新
没有蜡笔的小新 2021-01-28 10:42

Trying to figure out how to use character wrapping to mutate a string based on user input. If string is \'Bob loves to build building\' and user chooses to replace all letter B/

3条回答
  •  别那么骄傲
    2021-01-28 11:28

    I think there is a String class built-in replace function.

    String text = "Bob loves to build building";
    text = text.replace("B","T").replace("b","t");
    

    something like this ?

提交回复
热议问题