split()

2023. 4. 24. 00:28

💡 split() 메서드

➡️ 문자열이나 배열, 리스트에서 구분자로 분리하여 배열로 반환 

// 여기서는 구분자가 공백
String str = "This is a sentence.";
String[] words = str.split(" ");  // 배열의 각 요소는 공백으로 분리된 각 단어 [This, is, a, sentence.]

 

'Java > Method' 카테고리의 다른 글

replace()  (0) 2023.05.22
str.substring()  (0) 2023.04.22
Math.sqrt()  (0) 2023.04.22
str.replace(char oldChar, char newChar)  (0) 2023.04.22
Character.getNumericValue()  (0) 2023.04.22

BELATED ARTICLES

more