What is the difference between StringBuilder and StringBuffer classes.

Both the StringBuffer and StringBuilder classes are used to create mutable strings. But StringBuffer are synchronized, which means that only one task is allowed to execute the methods. Consider the following program which appends a “-” mark to a StringBuilder object by 100 threads. import java.util.concurrent.Executors; import java.util.concurrent.ThreadPoolExecutor; public class MutableStringDemo{ static StringBuilder stringBuilder =…… Continue reading What is the difference between StringBuilder and StringBuffer classes.