Java StringBuffer length() methodThe 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 1Test it NowOutput: total character count of "javatpoint": 10 total character count of "string l e ng th": 16 total character count: 0 Example 2In this example, we are calculating the length of the string by taking input from a user. Test it NowOutput: enter your string value: hello this is a string total input character: 22
Next TopicStringBuffer class
|