频道栏目
首页 > 资讯 > Java > 正文

Java字符串详解

12-04-27        来源:[db:作者]  
收藏   我要投稿

也行你知道,也许你不知道
一:
[java]
@Test 
public void test() { 
    long start = System.currentTimeMillis(); 
    String str = ""; 
    for(int i = 0 ; i < 499990 ;i++){ 
        str = str+i; 
    } 
    long end = System.currentTimeMillis(); 
    System.out.println(start); 
    System.out.println(end); 
    System.out.println((double)(end-start)/1000); 

1335404638171
1335406659968
2021.797
二:

[java] @Test 
    public void test2() { 
        long start = System.currentTimeMillis(); 
        StringBuffer str = new StringBuffer(); 
        for(int i = 0 ; i < 499999 ;i++){ 
            str.append(i); 
        } 
        long end = System.currentTimeMillis(); 
        System.out.println(start); 
        System.out.println(end); 
        System.out.println((double)(end-start)/1000); 
    } 

1335406936015
1335406936140
0.125

三:
[java]
@Test 
    public void test2() { 
        long start = System.currentTimeMillis(); 
        StringBuffer str = new StringBuffer(); 
        for(int i = 0 ; i < 1999999 ;i++){ 
            str.append(i); 
        } 
        long end = System.currentTimeMillis(); 
        System.out.println(start); 
        System.out.println(end); 
        System.out.println((float)(end-start)/1000); 
    } 

1335409426250
1335409426593
0.343

这下,你知道了吧



摘自 yasenagat的专栏

相关TAG标签
上一篇:凡客某频道SQL注入可导致用户名密码及其他敏感信息泄露
下一篇:Java继承详解
相关文章
图文推荐

关于我们 | 联系我们 | 广告服务 | 投资合作 | 版权申明 | 在线帮助 | 网站地图 | 作品发布 | Vip技术培训 | 举报中心

版权所有: 红黑联盟--致力于做实用的IT技术学习网站