Both StringBuilder() and StringBuffer() are classes part of java.lang package. there are differences exist between them. Following are the differences mentioned below:
StringBuilder() is not threadsafe and it is faster compare to StringBuilder() in terms of performance. Since it is not thread safe if multiple threads use same object it cause failures in parallel testing.
StringBuffer() is threadsafe and slower compare to StringBuilder() in terms of performance. Since it is thread safe it is better to use in parallel testing.
sukanya meruva Answered question