Javatpoint Logo
Javatpoint Logo

Java StringBuffer length() method

The length() method of Java StringBuffer class returns the length (total characters) of this sequence.

Syntax:

Parameter:

NA

Returns:

The length() method returns the total character count of this sequence.

Exception:

NA

Compatibility Version:

Java 1.0 and above

Example 1

Test it Now

Output:

total character count of "javatpoint": 10
total character count of "string l e ng th": 16
total character count: 0

Example 2

In this example, we are calculating the length of the string by taking input from a user.

Test it Now

Output:

enter your string value: hello this is a string
total input character: 22

Next TopicStringBuffer class





Youtube For Videos Join Our Youtube Channel: Join Now

Feedback


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA