Let's look into function of 'split'.
'Split' divides the string based on the character you choosed.
-----------------------------------------------------------------------------------
♠︎ String[] split(String regex)
Let me show you an example.
Like this, It is saved in array.
♠︎ String[] split(String regex, int limit)
This is the second way.
There is an example.
The limit is size of array.
So, even if you split spring to the selected character , things out of range are disregarded.
--------------------------------------------------------------------------------------------
✓ If you want to split string to '.' character, you should wirte down '\\ or \' in front of the character.
Because of 'meta character'.
In that case, you can use 'escape character'.
'develop' 카테고리의 다른 글
2주차 과제: 자바 데이터 타입, 변수 그리고 배열 (0) | 2021.02.24 |
---|---|
1주차 과제: JVM은 무엇이며 자바 코드는 어떻게 실행하는 것인가. (0) | 2021.02.21 |
[java] What is 'substring' ? (0) | 2021.02.11 |
난수 생성 (Random 클래스) (0) | 2021.02.10 |
split 으로 문자열 나눠 배열에 저장 (0) | 2021.02.10 |