What is a String Builder ?

Discussion in 'Strings, I/O, Formatting, Parsing' started by vbraojava, Oct 27, 2008.

  1. vbraojava

    vbraojava New Member

    StringBuilder objects are like String objects, except that they can be modified.

    Internally, these objects are treated like variable-length arrays that contain a sequence of characters. At any point, the length and content of the sequence can be changed through method invocations.
     
  2. vijayrayal

    vijayrayal New Member

    Hi,
    can you pls tell me the difference of StringBuilder and StringBuffer?
    Is StringBuilder exist in java?If it is there,can you pls tell the package?
    because In api,i search in java lang package for StringBuilder class,but i am unable find that class?

    Regards.
    vijayrayal
     
  3. vbraojava

    vbraojava New Member

    Hi Vijay,

    The main difference between StringBuffer and StringBuilder is that, the StringBuilder is not synchronized, means the methods of StringBuilder class are not synchronized (not thread safe), And in case of StringBuffer methods are synchronized (thread safe).

    Apart form that nothing is different, both are similar.

    - Whenever we want to write any application by taking care of thread safe then we must go for StringBuffer. In other cases you can use either StringBuffer or StringBuilder.
     
  4. vbraojava

    vbraojava New Member

    Hi Vijay,

    Yes, the StringBuilder class existed in Java. But the StringBuilder Class was introduced in J2SE 5.0 (originally called J2SE 1.5), so you cannot find the StringBuilder Class in API's of earlier versions of Java.

    Here you can find StringBuilder Class in J2SE 1.5 API
     
  5. anneroberts

    anneroberts Member

    The StringBuilder population. StringBuilder Questions are like string objects, but that they could make altered. Internally, these Questions would approached such as variable-length arrays that hold numerous an arrangement of characters. Toward whatever point, the length and content of the succession camwood be changed through strategy invocations.
     

Share This Page