<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: idnxchange</title>
    <description>The latest articles on DEV Community by idnxchange (@idnkxchange).</description>
    <link>https://dev.to/idnkxchange</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F528363%2Fadb4ae2b-b824-4291-bf60-e5adf6774469.JPG</url>
      <title>DEV Community: idnxchange</title>
      <link>https://dev.to/idnkxchange</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/idnkxchange"/>
    <language>en</language>
    <item>
      <title>String Buffer in C </title>
      <dc:creator>idnxchange</dc:creator>
      <pubDate>Thu, 03 Dec 2020 17:20:53 +0000</pubDate>
      <link>https://dev.to/idnkxchange/string-buffer-in-c-3g3g</link>
      <guid>https://dev.to/idnkxchange/string-buffer-in-c-3g3g</guid>
      <description>&lt;p&gt;BY IDN K-XCHANGE &lt;a href="https://www.dotnet.idn-kxchange.com/blogs/recent_posts"&gt;https://www.dotnet.idn-kxchange.com/blogs/recent_posts&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;StringBuffer class is used for storing string values and modifying it. It is mutable (modifiable), Consumes less memory during concatenation and performs faster than String.&lt;/p&gt;

&lt;p&gt;Example –&lt;/p&gt;

&lt;p&gt;public class Program {&lt;/p&gt;

&lt;p&gt;public static void main(String args[]) {&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  StringBuffer s = new StringBuffer("I am string buffer. ");

  s.append("I am better than string");

  Console.WriteLine(s); 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;}&lt;/p&gt;

&lt;p&gt;}&lt;/p&gt;

&lt;p&gt;Output- I am string buffer. I am better than string&lt;/p&gt;

&lt;p&gt;Methods of String Buffer –&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;append(String s)&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Updates the value of the object that invoked the method. The method takes boolean, char, int, long, Strings, etc.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;reverse()&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The method reverses the value of the StringBuffer object that invoked the method.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;delete(int start, int end)&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Deletes the string starting from the start index until the end index.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;insert(int offset, int i)&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;This method inserts a string s at the position mentioned by the offset.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;replace(int start, int end, String str)&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;This method replaces the characters in a substring of this StringBuffer with characters in the specified String.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;capacity()&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Returns the current capacity of the String buffer.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;charAt(int index)&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The specified character of the sequence currently represented by the string buffer, as indicated by the index argument, is returned.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;ensureCapacity(int minimumCapacity)&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Ensures that the capacity of the buffer is at least equal to the specified minimum.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;getChars(int srcBegin, int srcEnd, char[] dst, int dstBegin)&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Characters are copied from this string buffer into the destination character array dst.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;indexOf(String str)&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Returns the index within this string of the first occurrence of the specified substring.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;indexOf(String str, int fromIndex)&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Returns the index within this string of the first occurrence of the specified substring, starting at the specified index.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;lastIndexOf(String str)&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Returns the index within this string of the rightmost occurrence of the specified substring.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;lastIndexOf(String str, int fromIndex)&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Returns the index within this string of the last occurrence of the specified substring.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;length()&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Returns the length (character count) of this string buffer.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;setCharAt(int index, char ch)&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The character at the specified index of this string buffer is set to ch.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;setLength(int newLength)&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Sets the length of this String buffer.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;subSequence(int start, int end)&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Returns a new character sequence that is a subsequence of this sequence.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;substring(int start)&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Returns a new String that contains a subsequence of characters currently contained in this StringBuffer. The substring begins at the specified index and extends to the end of the StringBuffer.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;substring(int start, int end)&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Returns a new String that contains a subsequence of characters currently contained in this StringBuffer.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;toString()&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Converts to a string representing the data in this string buffer.&lt;/p&gt;

&lt;p&gt;Read more such blogs at &lt;a href="https://www.dotnet.idn-kxchange.com/blogs/recent_posts"&gt;https://www.dotnet.idn-kxchange.com/blogs/recent_posts&lt;/a&gt;&lt;/p&gt;

</description>
      <category>dotnetblogs</category>
      <category>dotnet</category>
      <category>dotnetcommunity</category>
      <category>dotnetarticles</category>
    </item>
  </channel>
</rss>
