<?xml version="1.0"?>
<rss version="2.0">
   <channel>
      <title>String vs StringBuffer by norhamiza mohd nor</title>
      <link>https://padlet.com/norhamizamohdnor/Javajtmk</link>
      <description>Discuss a comparison between String and StringBuffer in terms of method, definition or simple syntax example.tqvm for joining my class.</description>
      <language>en-us</language>
      <pubDate>2019-02-19 04:29:15 UTC</pubDate>
      <lastBuildDate>2025-11-24 14:22:16 UTC</lastBuildDate>
      <webMaster>hello@padlet.com</webMaster>
      <image>
         <url>https://padlet-assets.s3.amazonaws.com/icons/Pizza.png</url>
      </image>
      <item>
         <title>Asslm..</title>
         <author>norhamizamohdnor</author>
         <link>https://padlet.com/norhamizamohdnor/Javajtmk/wish/334510448</link>
         <description><![CDATA[<div>Students..discuss about the topic given</div>]]></description>
         <enclosure url="" />
         <pubDate>2019-02-24 02:56:49 UTC</pubDate>
         <guid>https://padlet.com/norhamizamohdnor/Javajtmk/wish/334510448</guid>
      </item>
      <item>
         <title>String vs StringBuffer (13DDT17F2033)</title>
         <author>mifchikalaboo09</author>
         <link>https://padlet.com/norhamizamohdnor/Javajtmk/wish/334510566</link>
         <description><![CDATA[<div><strong><em>String</em></strong> is immutable and fixed length.If we are creating string which cannot be changed. So once we have created a string object we cannot change the value of string.<br><br></div><div><strong><em>StringBuffer</em></strong><strong> </strong>is a  peerclass of string that provides almost all functionality of strings.StringBuffer represents mutable, grow able and writable.<br><br>String code :<br><br></div><pre>String str="hello";
 String strCon=str.concat("world");//return's new concatenated string,str not changed</pre><div>Stringbuffer code :<br><br></div><pre>StringBuffer strBuff=new StringBuffer("hello");
strBuff.append("world");//strBuff changed </pre>]]></description>
         <enclosure url="" />
         <pubDate>2019-02-24 02:58:10 UTC</pubDate>
         <guid>https://padlet.com/norhamizamohdnor/Javajtmk/wish/334510566</guid>
      </item>
      <item>
         <title>Zarul (13DDT17F2009)</title>
         <author>zaruliqkhmal021499</author>
         <link>https://padlet.com/norhamizamohdnor/Javajtmk/wish/334510665</link>
         <description><![CDATA[<div>String is immutable, if you try to alter their values, another object gets created, whereas StringBuffer and StringBuilder are mutable so they can change their values.</div>]]></description>
         <enclosure url="" />
         <pubDate>2019-02-24 02:59:29 UTC</pubDate>
         <guid>https://padlet.com/norhamizamohdnor/Javajtmk/wish/334510665</guid>
      </item>
      <item>
         <title>discuss macam mana puan?</title>
         <author>fiqriazli</author>
         <link>https://padlet.com/norhamizamohdnor/Javajtmk/wish/334510724</link>
         <description><![CDATA[]]></description>
         <enclosure url="" />
         <pubDate>2019-02-24 03:00:24 UTC</pubDate>
         <guid>https://padlet.com/norhamizamohdnor/Javajtmk/wish/334510724</guid>
      </item>
      <item>
         <title>Zarul (13DDT17F2009)</title>
         <author>zaruliqkhmal021499</author>
         <link>https://padlet.com/norhamizamohdnor/Javajtmk/wish/334510993</link>
         <description><![CDATA[<div>If your string can change, and will be accessed from multiple threads, use a StringBuffer because StringBuffer is synchronous so you have thread-safety.</div>]]></description>
         <enclosure url="" />
         <pubDate>2019-02-24 03:04:05 UTC</pubDate>
         <guid>https://padlet.com/norhamizamohdnor/Javajtmk/wish/334510993</guid>
      </item>
      <item>
         <title>Stringbuffer vs</title>
         <author>fatin1999asikin</author>
         <link>https://padlet.com/norhamizamohdnor/Javajtmk/wish/334511146</link>
         <description><![CDATA[]]></description>
         <enclosure url="https://padlet-uploads.storage.googleapis.com/359293168/629ede25d48e0520e233328186c7a9e6/1F368E61_D39C_47D0_A140_964C7C7DF71A.png" />
         <pubDate>2019-02-24 03:06:14 UTC</pubDate>
         <guid>https://padlet.com/norhamizamohdnor/Javajtmk/wish/334511146</guid>
      </item>
      <item>
         <title></title>
         <author>muzakkir_alias</author>
         <link>https://padlet.com/norhamizamohdnor/Javajtmk/wish/334511149</link>
         <description><![CDATA[<div>Muzakkir </div>]]></description>
         <enclosure url="" />
         <pubDate>2019-02-24 03:06:15 UTC</pubDate>
         <guid>https://padlet.com/norhamizamohdnor/Javajtmk/wish/334511149</guid>
      </item>
      <item>
         <title>String vs string buffer</title>
         <author>norazhargatot</author>
         <link>https://padlet.com/norhamizamohdnor/Javajtmk/wish/334511163</link>
         <description><![CDATA[]]></description>
         <enclosure url="https://padlet-uploads.storage.googleapis.com/359293405/28519d89aa8fc1fa3490dee80ea01fe2/string_vs_stringbuffer.png" />
         <pubDate>2019-02-24 03:06:29 UTC</pubDate>
         <guid>https://padlet.com/norhamizamohdnor/Javajtmk/wish/334511163</guid>
      </item>
      <item>
         <title>Mohamad Haridz Hakimi Bin Ghazali 13DDT17F2045</title>
         <author>haridzhakimi041</author>
         <link>https://padlet.com/norhamizamohdnor/Javajtmk/wish/334511311</link>
         <description><![CDATA[<div><strong><br>The Basics:<br></strong><br></div><div>String is an immutable class, it can't be changed. <a href="http://docs.oracle.com/javase/8/docs/api/java/lang/StringBuilder.html">StringBuilder</a> is a mutable class that can be appended to, characters replaced or removed and ultimately converted to a String StringBuffer is the original synchronized version of StringBuilder<br><br></div><div>You should prefer StringBuilder in all cases where you have only a single thread accessing your object.<br><br></div><div><strong>The Details:<br></strong><br></div><div>Also note that StringBuilder/Buffersaren't magic, they just use an Array as a backing object and that Array has to be re-allocated when ever it gets full. Be sure and create your StringBuilder/Bufferobjects large enough originally where they don't have to be constantly re-sized every time .append() gets called.<br><br></div><div>The re-sizing can get very degenerate. It basically re-sizes the backing Array to 2 times its current size every time it needs to be expanded. This can result in large amounts of RAM getting allocated and not used when StringBuilder/Bufferclasses start to grow large.<br><br></div><div>In Java String x = "A" + "B"; uses a StringBuilder behind the scenes. So for simple cases there is no benefit of declaring your own. But if you are building String objects that are large, say less than 4k, then declaring StringBuilder sb = StringBuilder(4096); is much more efficient than concatenation or using the <a href="http://docs.oracle.com/javase/8/docs/api/java/lang/StringBuilder.html#StringBuilder--">default constructor</a> which is only 16 characters. If your String is going to be less than 10k then initialize it with the constructor to 10k to be safe. But if it is initialize to 10k then you write 1 character more than 10k, it will get re-allocated and copied to a 20k array. So initializing high is better than to low.<br><br></div><div>In the auto re-size case, at the 17th character the backing Array gets re-allocated and copied to 32 characters, at the 33th character this happens again and you get to re-allocated and copy the Array into 64 characters. You can see how this degenerates to <strong>lots</strong> of re-allocations and copies which is what you really are trying to avoid using StringBuilder/Buffer in the first place.<br><br></div><div>This is from the JDK 6 Source code for AbstractStringBuilder<br><br></div><pre>   void expandCapacity(int minimumCapacity) {
    int newCapacity = (value.length + 1) * 2;
        if (newCapacity &lt; 0) {
            newCapacity = Integer.MAX_VALUE;
        } else if (minimumCapacity &gt; newCapacity) {
        newCapacity = minimumCapacity;
    }
        value = Arrays.copyOf(value, newCapacity);
    }</pre><div>A best practice is to initialize the StringBuilder/Buffer a little bit larger than you think you are going to need if you don't know right off hand how big the String will be but you can guess. One allocation of slightly more memory than you need is going to be better than lots of re-allocations and copies.<br><br></div><div>Also beware of initializing a StringBuilder/Buffer with a String as that will only allocated the size of the String + 16 characters, which in most cases will just start the degenerate re-allocation and copy cycle that you are trying to avoid. The following is straight from the Java 6 source code.<br><br></div><pre>public StringBuilder(String str) {
    super(str.length() + 16);
    append(str);
    }</pre><div>If you by chance do end up with an instance of StringBuilder/Buffer that you didn't create and can't control the constructor that is called, there is a way to avoid the degenerate re-allocate and copy behavior. Call <a href="http://docs.oracle.com/javase/8/docs/api/java/lang/StringBuilder.html#ensureCapacity-int-">.ensureCapacity()</a>with the size you want to ensure your resulting String will fit into.<br><br></div><div><strong>The Alternatives:<br></strong><br></div><div>Just as a note, if you are doing really <strong>heavy</strong> String building and manipulation, there is a much more performance oriented alternative called <a href="http://ahmadsoft.org/ropes/">Ropes</a>.<br><br></div><div>Another alternative, is to create a StringList implemenation by sub-classing ArrayList&lt;String&gt;, and adding counters to track the number of characters on every .append() and other mutation operations of the list, then override .toString() to create a StringBuilder of the exact size you need and loop through the list and build the output, you can even make that StringBuilder an instance variable and 'cache' the results of .toString() and only have to re-generate it when something changes.<br><br></div><div>Also don't forget about String.format()when building fixed formatted output, which can be optimized by the compiler as they make it better.</div>]]></description>
         <enclosure url="https://padlet-uploads.storage.googleapis.com/359293554/ca1a818473624ca96922497d1d2a18da/hqdefault.jpg" />
         <pubDate>2019-02-24 03:08:31 UTC</pubDate>
         <guid>https://padlet.com/norhamizamohdnor/Javajtmk/wish/334511311</guid>
      </item>
      <item>
         <title></title>
         <author>fiqriazli</author>
         <link>https://padlet.com/norhamizamohdnor/Javajtmk/wish/334511357</link>
         <description><![CDATA[<div>(13ddt17f1056)<br>String class is used to manipulate character strings that cannot be changed. Simply stated, objects of type String are read only and immutable. The StringBuffer class is used to represent characters that can be modified.<br><br><br></div>]]></description>
         <enclosure url="https://padlet-uploads.storage.googleapis.com/359292987/0d4dafe5724f7c9c14da781e2b0d3520/Screenshot_2019_02_24_11_08_09.png" />
         <pubDate>2019-02-24 03:09:22 UTC</pubDate>
         <guid>https://padlet.com/norhamizamohdnor/Javajtmk/wish/334511357</guid>
      </item>
      <item>
         <title>String Vs Stringbuff</title>
         <author>noraishahzulkefli</author>
         <link>https://padlet.com/norhamizamohdnor/Javajtmk/wish/334511358</link>
         <description><![CDATA[<div>;)</div>]]></description>
         <enclosure url="https://padlet-uploads.storage.googleapis.com/359292885/d8811bb615f0f3f9429fdb063dad7b34/10EB75A0_BD2B_48B7_8E30_AE323323D60C.jpeg" />
         <pubDate>2019-02-24 03:09:25 UTC</pubDate>
         <guid>https://padlet.com/norhamizamohdnor/Javajtmk/wish/334511358</guid>
      </item>
      <item>
         <title></title>
         <author>muzakkir_alias</author>
         <link>https://padlet.com/norhamizamohdnor/Javajtmk/wish/334511546</link>
         <description><![CDATA[<div>MUZAKKIR (13DDT17F1047)</div>]]></description>
         <enclosure url="https://padlet-uploads.storage.googleapis.com/359292924/76101533021a0a4f28d2dd9fbd86082a/class_String_vs_class_StringBuffer.jpg" />
         <pubDate>2019-02-24 03:11:51 UTC</pubDate>
         <guid>https://padlet.com/norhamizamohdnor/Javajtmk/wish/334511546</guid>
      </item>
      <item>
         <title></title>
         <author>zaruliqkhmal021499</author>
         <link>https://padlet.com/norhamizamohdnor/Javajtmk/wish/334511563</link>
         <description><![CDATA[]]></description>
         <enclosure url="https://padlet-uploads.storage.googleapis.com/359292998/7dda7cb307d0d538f92a61a1b3952758/Screenshot_2019_02_24_11_11_26_39.png" />
         <pubDate>2019-02-24 03:12:07 UTC</pubDate>
         <guid>https://padlet.com/norhamizamohdnor/Javajtmk/wish/334511563</guid>
      </item>
      <item>
         <title>PUTRI SYALLIA SYAFIQH BT MD ZAMREEY</title>
         <author></author>
         <link>https://padlet.com/norhamizamohdnor/Javajtmk/wish/334511658</link>
         <description><![CDATA[]]></description>
         <enclosure url="https://padlet-uploads.storage.googleapis.com/359293903/947986e44214db502556de29f71cb9c7/9F0185FF_682E_466B_915E_897ED5D9FF89.jpeg" />
         <pubDate>2019-02-24 03:13:20 UTC</pubDate>
         <guid>https://padlet.com/norhamizamohdnor/Javajtmk/wish/334511658</guid>
      </item>
      <item>
         <title></title>
         <author>adryzikryy</author>
         <link>https://padlet.com/norhamizamohdnor/Javajtmk/wish/334512236</link>
         <description><![CDATA[<div>MUHAMMAD ADRYZIKRY BIN MOHD YUSOFF (13DDT17F1048)</div>]]></description>
         <enclosure url="https://padlet-uploads.storage.googleapis.com/359293365/76d30ecad7b74b4a1fd479a6564472a1/E47419CF_E8DE_4AFE_948F_280E810A8EA4.jpeg" />
         <pubDate>2019-02-24 03:17:49 UTC</pubDate>
         <guid>https://padlet.com/norhamizamohdnor/Javajtmk/wish/334512236</guid>
      </item>
      <item>
         <title>(13ddt17f1056)</title>
         <author>fiqriazli</author>
         <link>https://padlet.com/norhamizamohdnor/Javajtmk/wish/334512554</link>
         <description><![CDATA[<div>String declaration and output</div>]]></description>
         <enclosure url="https://padlet-uploads.storage.googleapis.com/359292987/9e206bcae209daa9c530d59de2f827c0/Screenshot_2019_02_24_11_18_48_1.png" />
         <pubDate>2019-02-24 03:20:45 UTC</pubDate>
         <guid>https://padlet.com/norhamizamohdnor/Javajtmk/wish/334512554</guid>
      </item>
      <item>
         <title>ADIB AIZAT BIN ASLE@ROSLI(13DDT17F2017</title>
         <author></author>
         <link>https://padlet.com/norhamizamohdnor/Javajtmk/wish/334512571</link>
         <description><![CDATA[]]></description>
         <enclosure url="https://padlet-uploads.storage.googleapis.com/359293223/d7345118897c660fc6f3e179aa5d92ee/Screenshot_20190224_112037_Chrome.jpg" />
         <pubDate>2019-02-24 03:20:59 UTC</pubDate>
         <guid>https://padlet.com/norhamizamohdnor/Javajtmk/wish/334512571</guid>
      </item>
      <item>
         <title></title>
         <author>are_lif287</author>
         <link>https://padlet.com/norhamizamohdnor/Javajtmk/wish/334512577</link>
         <description><![CDATA[<div>CHE ALIF SHUHAIMAN BIN CHE KAMRUL<br>13DDT17F1036</div>]]></description>
         <enclosure url="https://padlet-uploads.storage.googleapis.com/359293436/cb6d015b8b2af7a3963de953281c03b6/20190224_112003.png" />
         <pubDate>2019-02-24 03:21:02 UTC</pubDate>
         <guid>https://padlet.com/norhamizamohdnor/Javajtmk/wish/334512577</guid>
      </item>
      <item>
         <title>(13ddt17f1056)</title>
         <author>fiqriazli</author>
         <link>https://padlet.com/norhamizamohdnor/Javajtmk/wish/334512688</link>
         <description><![CDATA[<div>StringBuffer</div>]]></description>
         <enclosure url="https://padlet-uploads.storage.googleapis.com/359292987/4c0f35fb662cd75a944872e5056e63af/Screenshot_2019_02_24_11_16_30_1.png" />
         <pubDate>2019-02-24 03:22:29 UTC</pubDate>
         <guid>https://padlet.com/norhamizamohdnor/Javajtmk/wish/334512688</guid>
      </item>
      <item>
         <title>method</title>
         <author>hisyam_5670</author>
         <link>https://padlet.com/norhamizamohdnor/Javajtmk/wish/334513256</link>
         <description><![CDATA[<div>Muhammad Hisyam bin Ismail<br>13DDT17F1032</div>]]></description>
         <enclosure url="https://padlet-uploads.storage.googleapis.com/359292895/428dba5dc83db3f0c8bbd466372f715c/java_day4_33_638.jpg" />
         <pubDate>2019-02-24 03:29:28 UTC</pubDate>
         <guid>https://padlet.com/norhamizamohdnor/Javajtmk/wish/334513256</guid>
      </item>
      <item>
         <title>difference</title>
         <author>hisyam_5670</author>
         <link>https://padlet.com/norhamizamohdnor/Javajtmk/wish/334513839</link>
         <description><![CDATA[]]></description>
         <enclosure url="https://padlet-uploads.storage.googleapis.com/359292895/04aabf409572c55f6feff4bd3050e6e9/java_string_handling_23_638.jpg" />
         <pubDate>2019-02-24 03:37:07 UTC</pubDate>
         <guid>https://padlet.com/norhamizamohdnor/Javajtmk/wish/334513839</guid>
      </item>
      <item>
         <title>String buffer reader</title>
         <author>norazhargatot</author>
         <link>https://padlet.com/norhamizamohdnor/Javajtmk/wish/334514030</link>
         <description><![CDATA[<div><strong>import</strong> java.io.*; <br><br></div><div><br><strong>class</strong> GFG { <br><br></div><div><br>    <strong>public</strong> <strong>static</strong> <strong>void</strong> main(String[] args) <br><br></div><div><br>    { <br><br></div><div><br>        StringBuffer s = <strong>new</strong> StringBuffer("Geeksfor"); <br><br></div><div><br>        s.append("Geeks"); <br><br></div><div><br>        System.out.println(s); // returns GeeksforGeeks <br><br></div><div><br>        s.append(1); <br><br></div><div><br>        System.out.println(s); // returns GeeksforGeeks1 <br><br></div><div><br>    } <br><br></div><div>} </div>]]></description>
         <enclosure url="" />
         <pubDate>2019-02-24 03:39:46 UTC</pubDate>
         <guid>https://padlet.com/norhamizamohdnor/Javajtmk/wish/334514030</guid>
      </item>
      <item>
         <title></title>
         <author>hisyam_5670</author>
         <link>https://padlet.com/norhamizamohdnor/Javajtmk/wish/334514314</link>
         <description><![CDATA[<div>Coding String</div>]]></description>
         <enclosure url="https://padlet-uploads.storage.googleapis.com/359292895/80dc411e43a793e9bf9a923187225739/20190224_114106.jpg" />
         <pubDate>2019-02-24 03:43:01 UTC</pubDate>
         <guid>https://padlet.com/norhamizamohdnor/Javajtmk/wish/334514314</guid>
      </item>
      <item>
         <title></title>
         <author>hisyam_5670</author>
         <link>https://padlet.com/norhamizamohdnor/Javajtmk/wish/334514365</link>
         <description><![CDATA[<div>coding stringbuffer</div>]]></description>
         <enclosure url="https://padlet-uploads.storage.googleapis.com/359292895/a91a76d22d3f353d35c645491e7ec20f/20190224_114046.jpg" />
         <pubDate>2019-02-24 03:43:49 UTC</pubDate>
         <guid>https://padlet.com/norhamizamohdnor/Javajtmk/wish/334514365</guid>
      </item>
      <item>
         <title>13DDT16F2032</title>
         <author>nurulalyaarosli</author>
         <link>https://padlet.com/norhamizamohdnor/Javajtmk/wish/334514612</link>
         <description><![CDATA[]]></description>
         <enclosure url="https://padlet-uploads.storage.googleapis.com/359295902/aac5391d277a2c42a779de5eda598df2/main_qimg_90ad27397b0524d4fc9459b6e43996a9.webp" />
         <pubDate>2019-02-24 03:47:10 UTC</pubDate>
         <guid>https://padlet.com/norhamizamohdnor/Javajtmk/wish/334514612</guid>
      </item>
      <item>
         <title></title>
         <author>dianakamarudin177</author>
         <link>https://padlet.com/norhamizamohdnor/Javajtmk/wish/334518243</link>
         <description><![CDATA[<div>Comparison between string and stringbuffer (13DDT17F2013 </div>]]></description>
         <enclosure url="https://padlet-uploads.storage.googleapis.com/359292903/abfcb307c9c4cec332d20f43920e4a72/string_vs_stringbuffer.png" />
         <pubDate>2019-02-24 04:31:26 UTC</pubDate>
         <guid>https://padlet.com/norhamizamohdnor/Javajtmk/wish/334518243</guid>
      </item>
      <item>
         <title>-13DDT17F2003-</title>
         <author>mrcocacola22</author>
         <link>https://padlet.com/norhamizamohdnor/Javajtmk/wish/334518982</link>
         <description><![CDATA[<div>Difference :</div>]]></description>
         <enclosure url="https://padlet-uploads.storage.googleapis.com/359300082/c9c54cfaeb560268f51d3826d026a23c/class_String_vs_class_StringBuffer.jpg" />
         <pubDate>2019-02-24 04:41:51 UTC</pubDate>
         <guid>https://padlet.com/norhamizamohdnor/Javajtmk/wish/334518982</guid>
      </item>
      <item>
         <title>Comparison string and stringbuffer</title>
         <author>nadhirahyunus97</author>
         <link>https://padlet.com/norhamizamohdnor/Javajtmk/wish/334519045</link>
         <description><![CDATA[]]></description>
         <enclosure url="https://padlet-uploads.storage.googleapis.com/359300110/68b49ff30ed9db425cd80e352e7facd3/IMG_20190224_124331.jpg" />
         <pubDate>2019-02-24 04:42:32 UTC</pubDate>
         <guid>https://padlet.com/norhamizamohdnor/Javajtmk/wish/334519045</guid>
      </item>
      <item>
         <title>String and stringbuffer  </title>
         <author>fiyahx12</author>
         <link>https://padlet.com/norhamizamohdnor/Javajtmk/wish/334527464</link>
         <description><![CDATA[]]></description>
         <enclosure url="https://padlet-uploads.storage.googleapis.com/359292946/c1a3ea6c7857996137920987dd57b8db/1S4Mz.png" />
         <pubDate>2019-02-24 06:23:54 UTC</pubDate>
         <guid>https://padlet.com/norhamizamohdnor/Javajtmk/wish/334527464</guid>
      </item>
   </channel>
</rss>
