我原來把數字變成字符串,使用""+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 閱讀(2083)
評論(8) 編輯 收藏 所屬分類:
Java