标签:stackoverflow问题精选 stringbuilder stringbuffer
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.append(""); } System.out.println(System.currentTimeMillis() - t); } { StringBuilder sb = new StringBuilder(); t = System.currentTimeMillis(); for (int i = N; i --> 0 ;) { sb.append(""); } System.out.println(System.currentTimeMillis() - t); } }}
【Stackoverflow好问题】StringBuilder和StringBuffer对比
标签:stackoverflow问题精选 stringbuilder stringbuffer
原文地址:http://blog.csdn.net/lizeyang/article/details/40042255