JAVA

4일차// 대표적인 String 메소드, / 수정 .replace

aesup 2021. 1. 14. 20:10
728x90
1
2
3
4
5
6
7
8
9
10
11
12
13
14
    // 수정
    
    // replace
    String str7 = "A*B*C*D";
    String reStr = str7.replace("*""");  //ABCD 출력 
    
    //new 엔 바꾸고 싶은 것 넣기
    System.out.println(reStr);
    
    String str88 = "나는 반드시 성공할 수 있  습니다.";
    
    String reStr2 = str88.replace("  "" "); 
    System.out.println(reStr2); 
    // 한칸 쭐이기도 가능하다.
cs

변수. replace( old char, new char);

.replace( 변경하고싶은내용 , 변경할 내용);

 

 

 

728x90