•   Basic of Java
  •   OOPs Concepts String
  • Java String


    Java String Methods


    Difference between StringBuffer and StringBuilder

    There are many differences between StringBuffer and StringBuilder. A list of differences between StringBuffer and StringBuilder are given below:

    No. String StringBuffer
    1) StringBuffer is synchronized i.e. thread safe. It means two threads can't call the methods of StringBuffer simultaneously. StringBuilder is non-synchronized i.e. not thread safe. It means two threads can call the methods of StringBuilder simultaneously.
    2) StringBuffer is less efficient than StringBuilder. StringBuilder is more efficient than StringBuffer.

    StringBuffer Example

    Flash Soon


    Output:

    StringBuilder Example

    Flash Soon


    Output:

    Performance Test of StringBuffer and StringBuilder

    Let's see the code to check the performance of StringBuffer and StringBuilder classes.

    Flash Soon


    Output:

    Copyright 2017 Design& Development