![Trending Articles on Technical and Non Technical topics](/images/trending_categories.jpeg)
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Java program to insert a String into a Substring of StringBuffer
The insert() method of the StringBuffer class inserts the String starting from an index specified in the parameter along with the string
The syntax of the insert method is −
original_string.insert( index , var)
where var is the variable to be inserted and index is the position where the variable var is to be inserted.
Let us see an example program −
Example
public class Example { public static void main(String[] args) { StringBuffer str = new StringBuffer("Hello World"); String a = "Wonderful "; str.insert(6, a); System.out.println(str); } }
Output
Hello Wonderful World
Advertisements