145. Using 'length( )' method with StringBuffer

length( ) method when used with StringBuffer gives the current length of the StringBuffer's object.


StringBuffer object = new StringBuffer("abcdef");

object.length( );  -> Gives the length of the object it is holding now (i.e. the length of "abcdef" text in this example -> i.e. 6 )

Lets implement this on Eclipse IDE:

1. Create 'lengthDemo' class under any project as shown below:

2. Save and Run the 'lengthDemo' class file
3. Observe that the output is displayed  in the console as shown below:

Download this project:

Click here to download this project containing the class file used in this post (You can download this project and import into Eclipse IDE  on your machine)

Please comment below to feedback or ask questions.

Using 'charAt( )' method with StringBuffer will be explained in the next post.

No comments: