StringBuffer insert() method in Java

In this tutorial, we will learn about StringBuffer insert() method in Java.

StringBuffer class in Java provides insert() method to insert one string into another.It is overloaded to accept values of all the simple types, plus Strings, Objects, and CharSequences. Like append( ), it calls String.valueOf( ) to obtain the string representation of the value it is called with. This string is then inserted
into the invoking StringBuffer object. These are a few of its forms:

Here, index specifies the index at which point the string will be inserted into the invoking StringBuffer object.



In the above program, we have used StringBuffer insert() method to insert simple types, Strings, Objects at specified index.

Related posts

Leave a Comment