Languages
[Edit]
EN

Java - replace part of string from given index

0 points
Created by:
Lia-Perez
565

In this article, we would like to show you how to replace part of string from given index in Java.

Quick solution:

 

Practical example using substring() method

Edit

In this example, we replace part of the text string - CD at index 1 that is 2 characters long. To do so we use substring() method and + operator to add strings and receive the result.

Output:

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.

Java - String (popular problems)

Java - replace part of string from given index
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