Results 1 to 3 of 3

Thread: String Builder

  1. #1
    whateverme is offline Member
    Join Date
    Oct 2010
    Posts
    51
    Rep Power
    0

    Default String Builder

    Hello there,
    I was just wondering, what does StringBuilder do?
    So lets say I have declared this

    StringBuilder sb = new StringBuilder();
    How do I use string builder in a program?
    What is the difference between string and string builder and string buffer?
    What's exactly the advantage of using this?

    Thanks

  2. #2
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

    Default

    StringBuffer is used to store character strings that will be changed. It automatically expands as needed, when you adding new. String objects not like that, cannot be changed.

    StringBuilder was added in Java 5. It is identical to StringBuffer except that it is not synchronized. Means you cannot access it from more than one thread at the same time.

  3. #3
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

Similar Threads

  1. String builder scramble word game
    By moncur in forum New To Java
    Replies: 4
    Last Post: 10-22-2010, 04:14 AM
  2. Best GUI Builder
    By ergon78 in forum SWT / JFace
    Replies: 1
    Last Post: 09-14-2010, 02:02 PM
  3. Finding and storing a word from a string builder
    By ao241 in forum Advanced Java
    Replies: 3
    Last Post: 06-28-2010, 01:46 PM
  4. Builder
    By AgentApe in forum New To Java
    Replies: 4
    Last Post: 12-02-2009, 10:33 PM
  5. string vs string builder??
    By j2vdk in forum New To Java
    Replies: 6
    Last Post: 09-08-2008, 10:38 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •