Languages
[Edit]
EN

Java - String substring() method example

5 points
Created by:
Geo-Baby
300

Short example:

In this post we cover usage of String substring() method with simple code examples.

We use Java String substring() method to get substring of given string based on provided indexes.

1. String substring(int beginIndex)

Edit

String substring with single parameter example. 

int beginIndex - begin index is inclusive.

Output:

2. String substring(int beginIndex, int endIndex)

Edit

String substring with 2 parameters example.

int beginIndex - begin index is inclusive

int endIndex    - end    index is exclusive

Output:

3. String substring(int beginIndex, int endIndex) - more complex example

Edit

Output:

References

Edit
1
Donate to Dirask
Our content is created by volunteers - like Wikipedia. If you think, the things we do are good, donate us. Thanks!
Join to our subscribers to be up to date with content, news and offers.
Native Advertising
🚀
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂

Join