자바 문자열 replace() 메서드
예시
모든 "l" 문자가 "p" 문자로 대체되는 새 문자열을 반환합니다.
String myStr = "Hello";
System.out.println(myStr.replace('l', 'p'));
정의 및 사용
이 replace()
메서드는 문자열에서 지정된 문자를 검색하고 지정된 문자가 대체되는 새 문자열을 반환합니다.
통사론
public String replace(char searchChar, char newChar)
매개변수 값
Parameter | Description |
---|---|
searchChar | A char , representing the character that
will be replaced by the new character |
newChar | A char , representing the character to
replace the searchChar with |
기술적 세부 사항
보고: | String 지정된 문자가 새 문자로 대체된 new . |
---|
❮ 문자열 메서드