Java String substring() Method


This is one of the articles from our Java Tutorial for Beginners.

The Java String substring() Method


When you set int beginIndex (for example: beginIndex number 3), the program copies all the information from that index number (in our case: 3) until and including the end.

When you set both int beginIndex and int endIndex (for example: beginIndex number 3 and endIndex 7), the program copies all the information from the beginning index number (in our case: 3) until, but not including the end index number (in our case: 7). In other words, the endIndex number is not included.

Keep in mind that index numbers start from zero. It will make more sense in practice.


If you run this code on your computer, you will see the following in the console:

love Java


You can find more articles in our Java Tutorial for Beginners. 


Самоучители--узнать детальнее--