Write a StringBuffer insert() program

Write a StringBuffer insert() program

Program
import java.util.Scanner;
public class Main
{
    public static void main(String args[])
    {
        String s;
        Scanner sc=new Scanner(System.in);
        System.out.println("Enter String : ");
        s=sc.nextLine();
        StringBuffer s1=new StringBuffer(s);
        System.out.println(s1.insert(7,'M'));
    }
}


Output:

Enter String : Sateesh
SateeshM


import java.util.Scanner;
public class Main
{
    public static void main(String args[])
    {
        String s;
        Scanner sc=new Scanner(System.in);
        System.out.println("Enter String : ");
        s=sc.nextLine();
        StringBuffer s1=new StringBuffer(s);
        System.out.println(s1.insert(7,"Kumar"));
    }
}


Output:

Enter String : Sateesh
SateeshKumar


Strings Handling In Java



More Questions


188 . Write a StringBuffer insert() program
189 . Write a StringBuffer delete() program
190 . Write a StringBuffer append() program
191 . Write a StringBuffer replace() Program
192 . Write a StringBuilder length program
193 . Write a StringBuilder charAt() method program
194 . Write a StringBuilder toLowerCase() Program
195 . Write a StringBuilder toUpperCase() program
196 . Write a StringBuilder concat() program
197 . Write a StringBuilder compareTo program
198 . Write a StringBuilder compareToIgnoreCase() Program