Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 |
Tags
- Pipelining
- python
- DoM
- architecture
- for
- data structure
- Class
- instruction
- github
- javascript
- Algorithm
- DATAPATH
- while
- html
- mysql
- XML
- Linux
- Java
- react
- DS
- computer
- CSS
- function
- MIPS
- control
- DB
- MacOS
- system
- php
- web
Archives
- Today
- Total
YYYEJI
[JAVA] Delimiter란? 본문
728x90

Delimiter은
특정 문자열로 문자를 구분해줍니다.
아래 예제를 통해
public static void main(String[] args) {
Scanner s = new Scanner ("2022/10/23");
s.useDelimiter("/");
while(s.hasNext()){
System.out.println(s.next());
}
}

코드 한 줄씩 설명해 드리겠습니다.
Scanner s = new Scanner ("2022/10/23");
✓ 현재 s 객체에 "2022/10/23"이 들어가 있습니다.
s.useDelimiter("/");
✓ s 객체를 "/" 기준으로 문자열을 나눕니다.
while(s.hasNext()){
System.out.println(s.next());
}
✓ s객체가 다음 줄이 있다면 while이 true입니다.
✓ "/"를 기준으로 잘린 문자열을 하나씩 출력합니다.
◡̈
'Java' 카테고리의 다른 글
[JAVA] 이클립스 The selection cannot be launched, and there are no recent launches 오류 해결하기 (0) | 2022.11.03 |
---|---|
[JAVA] 자바에서 주석(comment) 처리하는 방법 (0) | 2022.10.23 |
[JAVA] 사용자로부터 값 입력받기 (Scanner) (0) | 2022.10.23 |
[JAVA] 자바 console에 결과 출력하기 (0) | 2022.10.23 |
[JAVA] Truncates 란? (0) | 2022.10.23 |