본문 바로가기

develop

[java] What is 'substring' ?

Today, I met with problem i should use tool of substring to solve.

 

So, I investigated some sites and I studid that tool.

Let's start it!

 

First of all, It has two kinds of method.

 

 

❏ String substring(int index)

This method gets the String from the index position to the last character positon.

Let me show you an example.

 

This will print "345".

Because 'substring' starts from 0 not 1.

 

❏ String substring(int beginIndex, int endIndex)

This second method gets the String from the beginIndex position to the front of endIndex position.

Let me show you an example too.

 

This will print "34".

Keep in mind. not up to 5.

 

📌 If you try to get something out of range, you get an error.

--------------------------------------------------------------------------------------------