0% found this document useful (0 votes)
10 views2 pages

JAVA9

Uploaded by

Aditya Konnur
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views2 pages

JAVA9

Uploaded by

Aditya Konnur
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Program for String Buffer class:-

import java.util.*;

class strbuff

public static void main(String args[])

Scanner sc = new Scanner(System.in);

System.out.println("Enter First String : ");

StringBuffer str0 = new StringBuffer(sc.nextLine());

System.out.println("Enter Second String : ");

StringBuffer str1 = new StringBuffer(sc.nextLine());

System.out.println("Length of 1st String : "+(str0.length()));

System.out.println("Length of 2nd String : "+(str1.length()));

System.out.println("Concatinating Strings : "+(str0.append(str1)));

System.out.println("Insertion in 1st String : "+(str0.insert(0,"Hey ")));

System.out.println("Insertion in 2nd String : "+(str1.insert(0,"Morning ")));

System.out.println("Replace Operation on 1st String : "+(str0.replace(0,4,"Hello ")));

System.out.println("Replace Operation on 2nd String : "+


(str1.replace(0,3,"Goodeve")));

System.out.println("Delete a part of 1st String : "+(str0.delete(0,4)));

System.out.println("Reverse Operation on 2nd String : "+(str1.reverse()));

System.out.println("Capacity Operation on 1st String : "+(str0.capacity()));

System.out.println("CharAt Operation on 2nd String : "+(str1.charAt(7)));

System.out.println("Substring Operation on 2nd String : "+(str1.substring(11,14)));

}
Output:-

You might also like