Languages
[Edit]
EN

Java - add character to string

0 points
Created by:
Argon
617

In this article, we would like to show you how to add character to string in Java.

Quick solution:

 

1. Practical example using + operator

Edit

In this example, we add character at the end of the text String using + operator.

Output:

2. Practical example using String substring() method

Edit

In this example, we present how to add a character in the middle of the text String using substring() method.

Output:

3. Practical example using StringBuilder append() method

Edit

In this exmaple, we create a StringBuilder object and add both the char and the String to it using append() method.

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