

{"id":15031,"date":"2018-05-14T04:42:26","date_gmt":"2018-05-14T04:42:26","guid":{"rendered":"https:\/\/data-flair.training\/blogs\/?p=15031"},"modified":"2026-05-22T16:41:23","modified_gmt":"2026-05-22T11:11:23","slug":"stringbuffer-in-java","status":"publish","type":"post","link":"https:\/\/data-flair.training\/blogs\/stringbuffer-in-java\/","title":{"rendered":"StringBuffer in Java &#8211; Explore its Constructors &amp; Methods with Examples"},"content":{"rendered":"<p>We know that the human brain is capable of understanding words better than numbers. So, the only way to represent words in a program is through strings. How to take string input and how to manipulate strings are essential. However, the StringBuffer class enables programmers to take mutable string input and manipulate them at an ease. In this article, we will take a look at some of the most important StringBuffer methods in Java.<\/p>\n<h3>StringBuffer Class in Java<\/h3>\n<p>A string, in general, is a sequence of characters that is immutable in nature. But Java provides a class called StringBuffer that facilitates the programmer to create a string that is mutable in nature.<\/p>\n<p>Every class in Java has two main attributes:<br \/>\n1. Constructors<br \/>\n2. Methods<\/p>\n<p>Let us discuss the different constructors and methods that are part of the StringBuffer class.<\/p>\n<h3>What is a Java mutable string?<\/h3>\n<p>Before starting the discussion about StringBuffer methods and constructors, we must know what exactly a mutable string is. Thus, A string that facilitates modification is known as a mutable string. However, the StringBuffer and StringBuilder classes allow us to create mutable strings.<\/p>\n<h3>StringBuffer Constructors in Java<\/h3>\n<table>\n<tbody>\n<tr>\n<td><b>Constructor(Syntax)<\/b><\/td>\n<td><b>Description<\/b><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">StringBuffer()<\/span><\/td>\n<td><span style=\"font-weight: 400\">It is the default constructor of the StringBuffer class. This constructor creates an empty StringBuffer with an initial capacity of 16.<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">StringBuffer(String str)<\/span><\/td>\n<td><span style=\"font-weight: 400\">It is a parameterized constructor with a String as a parameter. This constructor creates a StringBuffer with the specified string.<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">StringBuffer(int capacity)<\/span><\/td>\n<td><span style=\"font-weight: 400\">It is a parameterized constructor with an integer as a parameter. This constructor creates an empty StringBuffer with the specified capacity as its length.<\/span><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h3>Let us discuss some of the important methods present in the Java StringBuffer class<\/h3>\n<h4>1. Java append()<\/h4>\n<p>This method is used to concatenate two strings. Therefore, <span style=\"font-weight: 400\">using the append() method in Java enables adding a string to the end of another string.\u00a0<\/span><\/p>\n<p><strong>Code to understand Java append() method:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">package com.DataFlair.Stringbuffer;\r\npublic class Append\r\n{\r\n    public static void main(String args[])\r\n    {  \r\n        StringBuffer str=new StringBuffer(\"Data\");  \r\n        str.append(\"Flair\");  \r\n        System.out.println(str);\r\n    }  \r\n}  \r\n<\/pre>\n<p><strong>The output of the above code:<\/strong><\/p>\n<div class=\"code-output\">DataFlair<\/div>\n<h4>2. Java insert()<\/h4>\n<p>The insert method inserts the given string into the StringBuffer object at the given position. However, the insert() method needs two parameters to be passed, which are:<\/p>\n<ul>\n<li>The first parameter is an integer value given at the position where the string will be added.<\/li>\n<li>The second parameter is a string itself that is to be added.<\/li>\n<\/ul>\n<p><strong>Code to understand Java insert() method:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">package com.DataFlair.Stringbuffer;\r\npublic class Insert\r\n{\r\n    public static void main(String args[])\r\n    {  \r\n        StringBuffer str=new StringBuffer(\"Data\");  \r\n        str.insert(4,\"Flair\"); \r\n        System.out.println(str);\r\n    }  \r\n} \r\n<\/pre>\n<p><strong>The output of the above code:<\/strong><\/p>\n<div class=\"code-output\">DataFlair<\/div>\n<h4>3. Java replace()<\/h4>\n<p>The Java replace() method replaces the StringBuffer object with the specified string at the specified position.<\/p>\n<p>However, It consists of the three parameters starting index and the ending index at which the string will be replaced and the third parameter is the new string that will replace the characters.<\/p>\n<p><strong>Code to understand Java replace() method:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">package com.DataFlair.Stringbuffer;\r\npublic class Replace\r\n{\r\n    public static void main(String args[])\r\n    {  \r\n        StringBuffer sb=new StringBuffer(\"Data\");  \r\n        sb.replace(2,3,\"Flair\");  \r\n        System.out.println(sb); \r\n    }  \r\n} \r\n<\/pre>\n<p><strong>The output of the above code:<\/strong><\/p>\n<div class=\"code-output\">DaFlaira<\/div>\n<h4>4. Java delete()<\/h4>\n<p>Java delete() method deletes the StringBuffer object from the specified position.<\/p>\n<p><strong>Code to understand Java delete() method:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">package com.DataFlair.Stringbuffer;\r\npublic class Delete\r\n{\r\n    public static void main(String args[])\r\n    {  \r\n        StringBuffer sb=new StringBuffer(\"DataFlair\");  \r\n        sb.delete(4,9);  \r\n        System.out.println(sb);\r\n    } \r\n}\r\n<\/pre>\n<p><strong>The output of the above code:<\/strong><\/p>\n<div class=\"code-output\">Data<\/div>\n<h4>5. Java reverse()The<\/h4>\n<p>Java reverse() method is used to reverse the String present in the StringBuffer object.<\/p>\n<p><strong>Code to understand Java reverse() method:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">package com.DataFlair.Stringbuffer;\r\npublic class Reverse\r\n{\r\n    public static void main(String args[])\r\n    {  \r\n        StringBuffer str=new StringBuffer(\"DataFlair\");  \r\n        str.reverse();  \r\n        System.out.println(str);\r\n    }  \r\n}  \r\n<\/pre>\n<p><strong>The output of the above code:<\/strong><\/p>\n<div class=\"code-output\">rialFataD<\/div>\n<h4>6. Java capacity()<\/h4>\n<p>The capacity() method returns the current capacity of the StringBuffer object. However, the default capacity of the StringBuffer object is 16. If the number of characters increases from its current capacity, it increases the capacity by:(old capacity*2)+2. For example, if your current capacity is 16, then the capacity will be calculated as: (16*2)+2= 34.<\/p>\n<p><strong>Code to understand Java capacity() method:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">package com.DataFlair.Stringbuffer;\r\npublic class Capacity\r\n{\r\n    public static void main(String args[])\r\n    {  \r\n        StringBuffer sb=new StringBuffer();  \r\n        System.out.println(sb.capacity()); \r\n        sb.append(\"DataFlair\");  \r\n        System.out.println(sb.capacity()); \r\n        sb.append(\"DataFlair is company that teaches programming!!!\");  \r\n        System.out.println(sb.capacity());\r\n    } \r\n}\r\n<\/pre>\n<p><strong>The output of the above code:<\/strong><\/p>\n<div class=\"code-output\">16<br \/>\n16<br \/>\n57<\/div>\n<h4>7. Java ensureCapacity()<\/h4>\n<p>The ensureCapacity() method ensures that the given capacity is the minimum limit to the current capacity. Although if the capacity is greater than the current capacity, the method increases the capacity by (old capacity*2)+2. For example, if your current capacity is 32, it will be (32*2)+2=66.<\/p>\n<p><strong>Code to understand Java ensureCapacity() method:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">package com.DataFlair.Stringbuffer;\r\npublic class EnsureCapacity\r\n{\r\n    public static void main(String args[])\r\n    {\r\n        StringBuffer sb=new StringBuffer();  \r\n        System.out.println(sb.capacity());  \r\n        sb.append(\"DataFlair\");  \r\n        System.out.println(sb.capacity());\r\n        sb.append(\"DataFlair is company that teaches programming!!!\");  \r\n        System.out.println(sb.capacity()); \r\n        sb.ensureCapacity(10);\r\n        System.out.println(sb.capacity());  \r\n        sb.ensureCapacity(50);\r\n        System.out.println(sb.capacity()); \r\n    }  \r\n}  \r\n<\/pre>\n<p><strong>The output of the above code:<\/strong><\/p>\n<div class=\"code-output\">16<br \/>\n16<br \/>\n57<br \/>\n57<br \/>\n57<\/div>\n<h4>8. Java deleteCharAt()<\/h4>\n<p>This method deletes the character at the specified index.<\/p>\n<p><strong>Code to understand Java deleteCharAt():<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">package com.DataFlair.Stringbuffer;\r\npublic class DeleteCharAt\r\n{\r\n    public static void main(String[] args) {\r\n    StringBuffer str = new StringBuffer(\"DataFlair\");\r\n    System.out.println(\"Original String is: \" + str);\r\n    str.deleteCharAt(1);\r\n    System.out.println(\"The String after deleting a character at 1st index: \" + str);\r\n    str.deleteCharAt(5);\r\n    System.out.println(\"The String after deleting a character at 5th index: \" + str);\r\n  }\r\n}\r\n<\/pre>\n<p><strong>The output of the above code:<\/strong><\/p>\n<div class=\"code-output\">Original String is: DataFlair<br \/>\nThe String after deleting a character at 1st index: DtaFlair<br \/>\nThe String after deleting a character at 5th index: DtaFlir<\/div>\n<h3>List of some of the other methods of the Java StringBuffer Class:<\/h3>\n<table>\n<tbody>\n<tr>\n<td><b>SL. No.<\/b><\/td>\n<td><b>Method Name and Return Type<\/b><\/td>\n<td><b>Description<\/b><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">1<\/span><\/td>\n<td><span style=\"font-weight: 400\">char charAt(int index)<\/span><\/td>\n<td><span style=\"font-weight: 400\">Using this method, we can return the character present at the specified index.<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">2<\/span><\/td>\n<td><span style=\"font-weight: 400\">int codePointAt(int index)<\/span><\/td>\n<td><span style=\"font-weight: 400\">However, this method returns the Unicode code point of the character at the specified index.<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">3<\/span><\/td>\n<td><span style=\"font-weight: 400\">int codePointBefore(int index)<\/span><\/td>\n<td><span style=\"font-weight: 400\">Using this method, we can return the Unicode code point of the character before the specified index<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">4<\/span><\/td>\n<td><span style=\"font-weight: 400\">int codePointCount(int beginIndex, int endIndex)<\/span><\/td>\n<td><span style=\"font-weight: 400\">Using this method, we can return the number of Unicode code points in the String between the two endpoints specified.<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">5<\/span><\/td>\n<td><span style=\"font-weight: 400\">void ensureCapacity(int minimumCapacity)<\/span><\/td>\n<td><span style=\"font-weight: 400\">This method ensures that the capacity of the StringBuffer object is at least equal to the given minimum capacity.<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">6<\/span><\/td>\n<td><span style=\"font-weight: 400\">void getChars(int sourceBegin, int sourceEnd, char[] destination, int destBegin)<\/span><\/td>\n<td><span style=\"font-weight: 400\">Using this method, we can copy the specified characters in a specific range to a specific destination character array.<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">7<\/span><\/td>\n<td><span style=\"font-weight: 400\">int indexOf(String str, int fromIndex)<\/span><\/td>\n<td><span style=\"font-weight: 400\">Using this method, we can return the first occurrence of the given substring from the given index.<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">8<\/span><\/td>\n<td><span style=\"font-weight: 400\">StringBuffer insert(int offset, String str)<\/span><\/td>\n<td><span style=\"font-weight: 400\">Using this method, we can insert the string into the specified string at the specified offset.<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">9<\/span><\/td>\n<td><span style=\"font-weight: 400\">int lastIndexOf(String str)<\/span><\/td>\n<td><span style=\"font-weight: 400\">Using this method, we can return the last occurrence of the given substring from the given index.<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">10<\/span><\/td>\n<td><span style=\"font-weight: 400\">void setCharAt(int index, char ch)<\/span><\/td>\n<td><span style=\"font-weight: 400\">Using this method, we can set a character at the specified index of the string.<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">11<\/span><\/td>\n<td><span style=\"font-weight: 400\">void setLength(int newLength)<\/span><\/td>\n<td><span style=\"font-weight: 400\">This method is used to change the length of a string and set the specified length.<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">12<\/span><\/td>\n<td><span style=\"font-weight: 400\">String substring(int start, int end)<\/span><\/td>\n<td><span style=\"font-weight: 400\">This method returns the portion of the string between the given range.<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">13<\/span><\/td>\n<td><span style=\"font-weight: 400\">String toString()<\/span><\/td>\n<td><span style=\"font-weight: 400\">This method converts a given data into a string and returns it.<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">14<\/span><\/td>\n<td><span style=\"font-weight: 400\">void trimToSize()<\/span><\/td>\n<td><span style=\"font-weight: 400\">This method is used to trim the size of the string.<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">15<\/span><\/td>\n<td><span style=\"font-weight: 400\">CharSequence subSequence(int start, int end)<\/span><\/td>\n<td><span style=\"font-weight: 400\">Using this method, we can return a new character sequence from the specified range of indexes.<\/span><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h3>Points to Remember:<\/h3>\n<ul>\n<li>java.lang.StringBuffer class extends the Object class.<\/li>\n<li>The StringBuffer class is implemented by the interfaces: Serializable, Appendable, and CharSequence.<\/li>\n<li>However, we can use multithreading in the StringBuffer class, if and only if all the methods are declared synchronized to work in a multithreaded environment.<\/li>\n<li>Although if an operation occurs involving a source sequence, the class synchronizes only on the StringBuffer operating, not on the source.<\/li>\n<li>The StringBuffer class inherits some of the methods from the Object class, which are: clone, equals, finalize, getClass, hashCode, notify, notifyAll.<\/li>\n<\/ul>\n<p>When it comes to string manipulation in a multithreaded environment, safety is paramount. Unlike its counterpart, StringBuilder, StringBuffer boasts thread safety. Thus, this means multiple threads can access and modify the same StringBuffer object concurrently without the risk of data corruption.<\/p>\n<p>The magic behind this lies in StringBuffer is synchronized methods of StringBuffer. However, Synchronization acts as a gatekeeper, ensuring only one thread can modify the object at a time. Therefore, this controlled access makes StringBuffer the ideal choice for applications where multiple threads need to collaborate on building or modifying the same string data.<\/p>\n<h3>Conclusion<\/h3>\n<p>So, we can see that StringBuffer helps ease the process of string manipulation, by mutating the string. That is why it is important to know the working of StringBuffer, as String Handling is a key aspect of programming. In this article, we saw how to implement different methods of the StringBuffer class into our program.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>We know that the human brain is capable of understanding words better than numbers. So, the only way to represent words in a program is through strings. How to take string input and how&#46;&#46;&#46;<\/p>\n","protected":false},"author":5,"featured_media":108868,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[32],"tags":[20773,13917,13918,13919,13922],"class_list":["post-15031","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-java","tag-java-stringbuffer","tag-stringbuffer-append-in-java","tag-stringbuffer-class-in-java","tag-stringbuffer-construcor","tag-stringbuffer-methods"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.4 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>StringBuffer in Java - Explore its Constructors &amp; Methods with Examples - DataFlair<\/title>\n<meta name=\"description\" content=\"StringBuffer in Java allows to append, replace, reverse, concatenate strings. Learn about constructors and methods in java StringBuffer.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/data-flair.training\/blogs\/stringbuffer-in-java\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"StringBuffer in Java - Explore its Constructors &amp; Methods with Examples - DataFlair\" \/>\n<meta property=\"og:description\" content=\"StringBuffer in Java allows to append, replace, reverse, concatenate strings. Learn about constructors and methods in java StringBuffer.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/data-flair.training\/blogs\/stringbuffer-in-java\/\" \/>\n<meta property=\"og:site_name\" content=\"DataFlair\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/DataFlairWS\/\" \/>\n<meta property=\"article:published_time\" content=\"2018-05-14T04:42:26+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2026-05-22T11:11:23+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/stringbuffer-methods-in-java.webp\" \/>\n\t<meta property=\"og:image:width\" content=\"1200\" \/>\n\t<meta property=\"og:image:height\" content=\"628\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/webp\" \/>\n<meta name=\"author\" content=\"DataFlair Team\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@DataFlairWS\" \/>\n<meta name=\"twitter:site\" content=\"@DataFlairWS\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"DataFlair Team\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"6 minutes\" \/>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"StringBuffer in Java - Explore its Constructors &amp; Methods with Examples - DataFlair","description":"StringBuffer in Java allows to append, replace, reverse, concatenate strings. Learn about constructors and methods in java StringBuffer.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/data-flair.training\/blogs\/stringbuffer-in-java\/","og_locale":"en_US","og_type":"article","og_title":"StringBuffer in Java - Explore its Constructors &amp; Methods with Examples - DataFlair","og_description":"StringBuffer in Java allows to append, replace, reverse, concatenate strings. Learn about constructors and methods in java StringBuffer.","og_url":"https:\/\/data-flair.training\/blogs\/stringbuffer-in-java\/","og_site_name":"DataFlair","article_publisher":"https:\/\/www.facebook.com\/DataFlairWS\/","article_published_time":"2018-05-14T04:42:26+00:00","article_modified_time":"2026-05-22T11:11:23+00:00","og_image":[{"width":1200,"height":628,"url":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/stringbuffer-methods-in-java.webp","type":"image\/webp"}],"author":"DataFlair Team","twitter_card":"summary_large_image","twitter_creator":"@DataFlairWS","twitter_site":"@DataFlairWS","twitter_misc":{"Written by":"DataFlair Team","Est. reading time":"6 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/data-flair.training\/blogs\/stringbuffer-in-java\/#article","isPartOf":{"@id":"https:\/\/data-flair.training\/blogs\/stringbuffer-in-java\/"},"author":{"name":"DataFlair Team","@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/person\/7f83c342f5d1632d6f7b4b0b0f447823"},"headline":"StringBuffer in Java &#8211; Explore its Constructors &amp; Methods with Examples","datePublished":"2018-05-14T04:42:26+00:00","dateModified":"2026-05-22T11:11:23+00:00","mainEntityOfPage":{"@id":"https:\/\/data-flair.training\/blogs\/stringbuffer-in-java\/"},"wordCount":1258,"commentCount":0,"publisher":{"@id":"https:\/\/data-flair.training\/blogs\/#organization"},"image":{"@id":"https:\/\/data-flair.training\/blogs\/stringbuffer-in-java\/#primaryimage"},"thumbnailUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/stringbuffer-methods-in-java.webp","keywords":["Java stringbuffer","stringbuffer append in Java","StringBuffer Class in java","StringBuffer Construcor","StringBuffer Methods"],"articleSection":["Java Tutorials"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/data-flair.training\/blogs\/stringbuffer-in-java\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/data-flair.training\/blogs\/stringbuffer-in-java\/","url":"https:\/\/data-flair.training\/blogs\/stringbuffer-in-java\/","name":"StringBuffer in Java - Explore its Constructors &amp; Methods with Examples - DataFlair","isPartOf":{"@id":"https:\/\/data-flair.training\/blogs\/#website"},"primaryImageOfPage":{"@id":"https:\/\/data-flair.training\/blogs\/stringbuffer-in-java\/#primaryimage"},"image":{"@id":"https:\/\/data-flair.training\/blogs\/stringbuffer-in-java\/#primaryimage"},"thumbnailUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/stringbuffer-methods-in-java.webp","datePublished":"2018-05-14T04:42:26+00:00","dateModified":"2026-05-22T11:11:23+00:00","description":"StringBuffer in Java allows to append, replace, reverse, concatenate strings. Learn about constructors and methods in java StringBuffer.","breadcrumb":{"@id":"https:\/\/data-flair.training\/blogs\/stringbuffer-in-java\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/data-flair.training\/blogs\/stringbuffer-in-java\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/data-flair.training\/blogs\/stringbuffer-in-java\/#primaryimage","url":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/stringbuffer-methods-in-java.webp","contentUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/stringbuffer-methods-in-java.webp","width":1200,"height":628,"caption":"stringbuffer methods in java"},{"@type":"BreadcrumbList","@id":"https:\/\/data-flair.training\/blogs\/stringbuffer-in-java\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Blog Home","item":"https:\/\/data-flair.training\/blogs\/"},{"@type":"ListItem","position":2,"name":"Java Tutorials","item":"https:\/\/data-flair.training\/blogs\/category\/java\/"},{"@type":"ListItem","position":3,"name":"StringBuffer in Java &#8211; Explore its Constructors &amp; Methods with Examples"}]},{"@type":"WebSite","@id":"https:\/\/data-flair.training\/blogs\/#website","url":"https:\/\/data-flair.training\/blogs\/","name":"DataFlair","description":"Learn Today. Lead Tomorrow.","publisher":{"@id":"https:\/\/data-flair.training\/blogs\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/data-flair.training\/blogs\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/data-flair.training\/blogs\/#organization","name":"DataFlair","url":"https:\/\/data-flair.training\/blogs\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/logo\/image\/","url":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2016\/07\/Data-Flair.png","contentUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2016\/07\/Data-Flair.png","width":106,"height":48,"caption":"DataFlair"},"image":{"@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/DataFlairWS\/","https:\/\/x.com\/DataFlairWS","https:\/\/www.linkedin.com\/company\/dataflair-web-services-pvt-ltd\/","https:\/\/www.youtube.com\/user\/DataFlairWS"]},{"@type":"Person","@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/person\/7f83c342f5d1632d6f7b4b0b0f447823","name":"DataFlair Team","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/4cf3a74600d131330b8c481d519afd1574093ed89f6d3396a95393ad223eb7cd?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/4cf3a74600d131330b8c481d519afd1574093ed89f6d3396a95393ad223eb7cd?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/4cf3a74600d131330b8c481d519afd1574093ed89f6d3396a95393ad223eb7cd?s=96&d=mm&r=g","caption":"DataFlair Team"},"description":"DataFlair Team creates expert-level guides on programming, Java, Python, C++, DSA, AI, ML, data Science, Android, Flutter, MERN, Web Development, and technology. Our goal is to empower learners with easy-to-understand content. Explore our resources for career growth and practical learning.","url":"https:\/\/data-flair.training\/blogs\/author\/dfteam1\/"}]}},"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts\/15031","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/comments?post=15031"}],"version-history":[{"count":19,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts\/15031\/revisions"}],"predecessor-version":[{"id":148405,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts\/15031\/revisions\/148405"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/media\/108868"}],"wp:attachment":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/media?parent=15031"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/categories?post=15031"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/tags?post=15031"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}