import java.util.Arrays;
public class Application {
public static void main(String[] args) {
String s = "안녕하세요,반갑습니다,감사합니다,";
System.out.println(Arrays.toString(s.split(","))); //공백 무시
System.out.println(Arrays.toString(s.split(",", -1))); //공백 포함
}
}
split 메서드를 이용할 때 기준 문자와 함께 음수를 넣어주면 마지막 공백도 포함된다. (두번째 출력문)
'JAVA' 카테고리의 다른 글
Enum(열거형) (0) | 2021.12.21 |
---|---|
Static import 개념 및 사용법 (0) | 2021.11.26 |
Version of the JVM is not suitable for this product 에러 (0) | 2021.11.08 |
맥OS 자바 제어판이 열리지 않을 때 해결 (0) | 2021.11.08 |
[Chapter 05 문자열, 배열, 디버깅] 프로그래밍 문제 답 (2) | 2019.10.25 |
댓글