VOOZH about

URL: https://www.geeksforgeeks.org/java/stringbuilder-length-in-java-with-examples/

⇱ StringBuilder length() in Java with Examples - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

StringBuilder length() in Java with Examples

Last Updated : 15 Oct, 2018
The length() method of StringBuilder class returns the number of character the StringBuilder object contains. The length of the sequence of characters currently represented by this StringBuilder object is returned by this method. Syntax:
public int length()
Return Value: This method returns length of sequence of characters contained by StringBuilder object. Below programs demonstrate the length() method of StringBuilder Class: Example 1:
Output:
String = WelcomeGeeks
length of String = 12
Example 2:
Output:
String = India is Great
length of String = 14
Reference: https://docs.oracle.com/javase/10/docs/api/java/lang/StringBuilder.html#length()
Comment