Friday, 4 July 2014

How to remove the last character in StringBuilder

How to remove the last character in StringBuilder


package com.vipul;

public class StringBufferDelete {

      /**
      * How to remove the last character in StringBuilder
      * @param args
      */
      public static void main(String[] args) {
            String text2 = "Test";         
              StringBuffer text=new StringBuffer(text2);
           // ...
           final int length = text.length();
           if ( length > 0 ) {
                // We have remove the last character.
                text.deleteCharAt( length - 1 );
           }
           System.out.println(text);
      }

}

==========================================================================
Maven + eclipse related 
An internal error occurred during: "Importing Maven projects". Unsupported IClasspathEntry kind=4 fixed

==================================================================================

No comments:

Post a Comment