Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I dunno. Let's go see:</p> <ul> <li><a href="http://www.docjar.com/html/api/java/lang/StringBuilder.java.html" rel="noreferrer">http://www.docjar.com/html/api/java/lang/StringBuilder.java.html</a></li> </ul> <blockquote> <pre><code>72 public final class StringBuilder 73 extends AbstractStringBuilder </code></pre> </blockquote> <ul> <li><a href="http://www.docjar.com/html/api/java/lang/AbstractStringBuilder.java.html" rel="noreferrer">http://www.docjar.com/html/api/java/lang/AbstractStringBuilder.java.html</a></li> </ul> <blockquote> <pre><code>45 * The value is used for character storage. 46 */ 47 char[] value; 48 49 /** 50 * The count is the number of characters used. 51 */ 52 int count; </code></pre> </blockquote> <p>===</p> <blockquote> <p>Is StringBuilder an array of characters too?</p> </blockquote> <p>Apparently, in this particular implementation.</p> <blockquote> <p>So, I have a StringBuilder MY_OBJ= "Hello". Now if i try to append characters to the end of MY_OBJ, does it not mean that you are actually creating a new array object and copying all these chars into a new one? </p> </blockquote> <p>Not necessarily. The array isn't necessarily full (<code>count &lt; value.length</code>), so a new array may not need to be allocated. Ideally, you initialized StringBuilder a capacity so that large enough array was allocated from the start.</p> <pre><code>StringBuilder sb = new StringBuilder(20); sb.append("Hello"); ... sb.append(" there"); </code></pre> <blockquote> <p>And another question I have in mind is, how does one mark the end of a StringBuilder? Like in C, we use a "/0"</p> </blockquote> <p>You don't care - <code>String/StringBuilder</code> will handle it internally.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload