Results 1 to 7 of 7
  1. #1
    j2vdk's Avatar
    j2vdk is offline Member
    Join Date
    Aug 2008
    Posts
    45
    Rep Power
    0

    Default string vs string builder??

    what is the differences between string and string builder??

  2. #2
    Supamagier is offline Senior Member
    Join Date
    Aug 2008
    Posts
    384
    Rep Power
    7

    Default

    StringBuilder has some extra options, like StringBuilder.append(String); They're both the same, regarding speed.
    I die a little on the inside...
    Every time I get shot.

  3. #3
    daGame is offline Member
    Join Date
    May 2008
    Posts
    24
    Rep Power
    0

    Default

    Quote Originally Posted by j2vdk View Post
    what is the differences between string and string builder??
    I recomend you to google around for such simple questions, that saves your time too, take a look on how many hits you will receive when you search for them. ;)

    regards,

    daGame

  4. #4
    masijade is offline Senior Member
    Join Date
    Jun 2008
    Posts
    2,571
    Rep Power
    9

    Default

    Quote Originally Posted by Supamagier View Post
    StringBuilder has some extra options, like StringBuilder.append(String); They're both the same, regarding speed.
    Actually, if you are building a String using all, or at least mostly, String literals, then simple String and + is faster (as most, if not all, of those operations will be optimized away by the compiler). However, if you are doing alot of String manipulation actions (additions, insertions, modifications, etc, etc) then StringBuilder is faster (not String Buffer as that is "thread-safe", so there is a lot of unnecessary syncs if threadedness doesn't factor into it's use in that situation).

    The difference between String operations and StringBuilder is, however, minimal and not likely to make any difference, unless you are performing a few thousand such operations per second.

  5. #5
    daGame is offline Member
    Join Date
    May 2008
    Posts
    24
    Rep Power
    0

    Default

    Quote Originally Posted by Supamagier View Post
    They're both the same, regarding speed.
    I suggest you to read this Difference b/w String, StringBuffer and StringBuilder - Performance (Java in General (beginner) forum at JavaRanch)

    :)

    regards,

    daGame

  6. #6
    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

    Strings are immutable, while StringBuliders(StringBuffers also) are mutable. That means you can change the value.

  7. #7
    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

    Quote Originally Posted by Supamagier View Post
    StringBuilder has some extra options, like StringBuilder.append(String); They're both the same, regarding speed.
    Similar option is available for String objects as well. concat(String)

Similar Threads

  1. Replies: 2
    Last Post: 09-18-2008, 07:30 AM
  2. Replies: 0
    Last Post: 11-20-2007, 04:59 PM
  3. Replies: 1
    Last Post: 08-07-2007, 07:29 AM
  4. Replies: 1
    Last Post: 08-03-2007, 10:52 AM
  5. Help with NetBeans 5 GUI builder
    By Daniel in forum NetBeans
    Replies: 2
    Last Post: 07-04-2007, 07:08 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
  •