by Dinesh Thakur Category: array

int length (): This method returns the number of characters currently in the invoking string buffer. For example,

str1.1ength ()

will return 10, which is the number of characters in the string literal Welcome that is referenced by strl.

public class StringLength

{
         public static void main(String[] args)
    {
            StringBuffer s1 = new StringBuffer();
            StringBuffer s2 = new StringBuffer(35);
            StringBuffer s3 = new StringBuffer("Hello Java");
            System.out.println("s1.length() =  "  + s1.length());
            System.out.println("s2.length()  = " + s2.length());
            System.out.println("s3.length() =  "  + s3.length());
           
     }
}

Stringbuffer Length() in Java Example

About Dinesh Thakur

Dinesh ThakurDinesh Thakur holds an B.SC (Computer Science), MCSE, MCDBA, CCNA, CCNP, A+, SCJP certifications. Dinesh authors the hugely popular blog. Where he writes how-to guides around Computer fundamental , computer software, Computer programming, and web apps. For any type of query or something that you think is missing, please feel free to Contact us.



Search Content







Popular Article