Answer to Question #224065 in Java | JSP | JSF for Piu

Question #224065

Write a program that show working of different functions of String and

StringBuffer classs like setCharAt(), setLength(), append(), insert(), concat()and

equals().


1
Expert's answer
2021-08-09T02:34:25-0400


public class Main
{
	public static void main(String[] args) {
		//setCharAt()
		StringBuffer str= new StringBuffer("Computer");
		str.setCharAt(7, '0');
		//setLength()
		str.setLength(10);
		//append()
		str.append("Science");
		//insert()
		str.insert(10,true);
		//concat()
		String s2=" of Science";
		String s1="BCS ".concat(s2);
		//equals()
		StringBuffer sa = new StringBuffer("abd");
        StringBuffer sb = new StringBuffer("abc");
        System.out.println(sa.equals(sb));
	}
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS