In this article, we will see how to use StringBuilder insert method in Java.
The StringBuilder in Java provides a modifiable sequence of char acters. The String Class in Java creates and immutable sequence of char acters, the StringBuilder class provides an alternate to String Class, as it creates a mutable sequence of char acters.
The Java StringBuilder class is same to StringBuffer class, except it is non-synchronized.
Insert method allows us to insert a string into another with giving an insert point.
Lets look to our code.
StringBuilder x = new StringBuilder("andromeda");
x.insert(5,"vega");
Lets see it in an example.
In above example, we created a StringBuilder object. We used its insert method to insert one string into another string .