Difference between StringBuilder and StringBuffer
问题 What is the main difference between StringBuffer and StringBuilder ? Is there any performance issues when deciding on any one of these? 回答1: StringBuffer is synchronized, StringBuilder is not. 回答2: StringBuilder is faster than StringBuffer because it's not synchronized . Here's a simple benchmark test: public class Main { public static void main(String[] args) { int N = 77777777; long t; { StringBuffer sb = new StringBuffer(); t = System.currentTimeMillis(); for (int i = N; i --> 0 ;) { sb