StringBulider class

String StringBulider class created can also be modified string:

public  class StringBuliderDemo {
     public  static  void main (String [] args) { 
    the StringBuilder SB = new new the StringBuilder (); 
    sb.append ( " 1234 " ); // add a string 
    sb.insert ( 2 , " dont " ); // is inserted at the specified location, 
    sb.delete ( . 1 , . 4 ); // delete, including the header, does not include the tail 
    sb.replace ( . 1 , . 4 , " not " ); // replace the contents within the specified range, comprising a head, not included tail
    STR = String sb.toString (); 
    the System. OUT .println (STR); 
    the System. OUT .println (sb.reverse ()); // inverting 
    the System. OUT .println ( " length of string: " + sb.length ()); 
} 
}

 

Guess you like

Origin www.cnblogs.com/zhai1997/p/11348864.html