TestString.java 402 B

1234567891011121314151617
  1. package J20250715.testString;
  2. /**
  3. * @author WanJl
  4. * @version 1.0
  5. * @title TestString
  6. * @description
  7. * replace(char oldChar, char newChar) 将字符串中所有的oldChar都换成newChar
  8. * @create 2025/7/15
  9. */
  10. public class TestString {
  11. public static void main(String[] args) {
  12. String s="hello world";
  13. String s1 = s.replace('l', 'z');
  14. System.out.println(s1);
  15. }
  16. }