Results 1 to 2 of 2
  1. #1
    Join Date
    Dec 2010
    Posts
    1
    Rep Power
    0

    Default Why we use String compare to String Buffer

    Hi There,
    We know that String is immutable and StringBuffer is mutable. But still why we go with String rather than StringBuffer. What is the main reason for using String than using StringBuffer. Please explain in detail.. :)

  2. #2
    Singing Boyo is offline Senior Member
    Join Date
    Mar 2009
    Posts
    552
    Rep Power
    6

    Default

    Because it just seems to end up working that way... The immutability of Strings is probably based in the fact that C/C++ strings are const char arrays. Why we use Strings is based on that fact that java converts string literals to String, not some other class (such as StringBuffer.
    If the above doesn't make sense to you, ignore it, but remember it - might be useful!
    And if you just randomly taught yourself to program, well... you're just like me!

Similar Threads

  1. Replies: 8
    Last Post: 02-22-2014, 08:06 AM
  2. How compare two String?
    By artemff in forum New To Java
    Replies: 8
    Last Post: 08-29-2011, 08:00 AM
  3. compare sql resultset with a String
    By cotarelo in forum Networking
    Replies: 6
    Last Post: 06-21-2010, 03:53 PM
  4. Non Allocating String Buffer
    By chrisdb89 in forum New To Java
    Replies: 5
    Last Post: 10-25-2008, 06:57 AM
  5. Help with String Buffer
    By mathias in forum AWT / Swing
    Replies: 1
    Last Post: 08-07-2007, 06:52 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
  •