
- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Get the length of a StringBuffer Object in Java
To find the length of the StringBuffer object, the length() function is used. It is a method of the StringBuffer Class. The method returns the count of characters in the sequence.
Declaration- The java.lang.StringBuffer.length() method is declared as follows −
public int length()
Let us see an example program illustrating the use of length() method −
Example
public class Example { public static void main(String[] args) { StringBuffer sb = new StringBuffer("Hello World"); int len = sb.length(); // computes the length of the StringBuffer Object System.out.println(len); } }
Output
11
- Related Questions & Answers
- Change the length of the StringBuffer Object in Java
- Get the capacity of the StringBuffer Object in Java
- Reverse the sequence of characters in a StringBuffer Object in Java
- Change the default capacity of the StringBuffer Object in Java
- Set the capacity value for a StringBuffer object in Java
- Remove a character from a Java StringBuffer object
- What is the difference between a String object and a StringBuffer object in java?
- Change a single character in a Java StringBuffer object in Java
- Remove characters in a range from a Java StringBuffer Object
- How to get the length of an object in JavaScript?
- Call append() method to construct a StringBuffer object in Java
- How to get the Length of a String in Java?
- Finding the length of a JavaScript object
- Get the Name of a Member Object in Java
- Length of a JavaScript object?
Advertisements