尝试找出如何使用字符换行来根据用户输入改变字符串。如果字符串是“Boblovestobuildbuilding”并且用户选择用T/t替换所有字母B/b,我需要如何编码才能得到“Tomlovestotuildtuildings”?
最佳答案
我认为 String 类有一个内置的替换函数。
String text = "Bob loves to build building";
text = text.replace("B","T").replace("b","t");
类似这样的东西?
关于java - 使用字符包装器编写代码,用保留原始大小写的新字母替换字符串中的字母,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12399724/