본문 바로가기

develop

[java] What is 'split' ?

 

 

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'.