posts - 41,  comments - 40,  trackbacks - 0

          我原來把數字變成字符串,使用""+1000,但是經過測試,發現,,,呵呵,你自己測試吧:

          public final class WhoFaster2
          {
          ? public static void main( String[] args )
          ? {
          ??? long times=1000000L;? //百萬

          ??? long start=0L;

          ??? String temp=null;

          ??? /*/
          ??? start=System.currentTimeMillis();

          ??? temp=null;

          ??? for( int i=0; i<times; i++ )
          ?????? {
          ???????? temp=times+"";
          ?????? }

          ??? System.out.println( temp+" "+( System.currentTimeMillis()-start ) );
          ??? /*/
          ??? start=System.currentTimeMillis();

          ??? temp=null;

          ??? for( int i=0; i<times; i++ )
          ?????? {
          ???????? temp=Long.toString( times );
          ?????? }

          ??? System.out.println( temp+" "+( System.currentTimeMillis()-start ) );
          ??? //*/
          ? }
          }

          posted on 2007-09-17 01:23 NeedJava 閱讀(2092) 評論(8)  編輯  收藏 所屬分類: Java
          主站蜘蛛池模板: 高安市| 通海县| 车致| 兰溪市| 辽宁省| 两当县| 上杭县| 攀枝花市| 长岛县| 安康市| 神池县| 含山县| 中方县| 全南县| 开封县| 商河县| 顺昌县| 新沂市| 报价| 连南| 惠州市| 青田县| 阿鲁科尔沁旗| 资源县| 高陵县| 宿州市| 威宁| 惠安县| 新宾| 临清市| 湟源县| 尤溪县| 凤凰县| 辉南县| 汤阴县| 巫溪县| 岢岚县| 阳高县| 富锦市| 大安市| 常州市|