StringBuffer In Java
StringBuffer In Java:
package one;
public class StringBuffer {
public static void main(String[] args) {
java.lang.StringBuffer sb=new java.lang.StringBuffer("Hello ");
System.out.println(sb.capacity());
sb.append("Java");
System.out.println(sb);
sb.insert(2," haha ");
System.out.println(sb);
sb.replace(1, 4, "huhuhuhu");
System.out.println(sb);
sb.ensureCapacity(10);
System.out.println(sb.capacity());
sb.delete(1, 18);
System.out.println(sb);
System.out.println(sb.capacity());
sb.reverse();
System.out.println(sb);
}
}
package one;
public class StringBuffer {
public static void main(String[] args) {
java.lang.StringBuffer sb=new java.lang.StringBuffer("Hello ");
System.out.println(sb.capacity());
sb.append("Java");
System.out.println(sb);
sb.insert(2," haha ");
System.out.println(sb);
sb.replace(1, 4, "huhuhuhu");
System.out.println(sb);
sb.ensureCapacity(10);
System.out.println(sb.capacity());
sb.delete(1, 18);
System.out.println(sb);
System.out.println(sb.capacity());
sb.reverse();
System.out.println(sb);
}
}
Comments
Post a Comment