예) 공백을 가지는 str 스트링 변수 : ab c de f
의 공백을 모드 없애고 싶다며 이렁게 replace 를 이용하세요
이렇게 => str = str.replace(" ", "" ); 사용하면 공백은 모두 사라지고
그러면 결과는 : abcdef 가 됩니다.
public String replace (char oldChar, char newChar)
public String replace (char oldChar, char newChar)
Since: API Level 1
Since: API Level 1
Copies this string replacing occurrences of the specified character with another character.
Copies this string replacing occurrences of the specified character with another character.
Parameters
Parameters
oldChar
the character to replace.
newChar
the replacement character.
Returns
- a new string with occurrences of oldChar replaced by newChar.
oldChar | the character to replace. |
---|---|
newChar | the replacement character. |
Returns
- a new string with occurrences of oldChar replaced by newChar.
'프로그래밍 > Java' 카테고리의 다른 글
[펌]개발자가 놓치기 쉬운 자바의 기본원리 (0) | 2011.02.20 |
---|---|
[펌]이클립스 속도 향상(eclipse.ini 수정) (0) | 2010.11.06 |
Eclipse Package Explorer 보기쉽게 이용하기 (0) | 2010.04.22 |
[팁/J2ME]java.long.Error:Unresolved compilation problem (0) | 2010.04.15 |
static 과 final (0) | 2010.04.06 |