效率"/>
java string 效率
package com.supan.test;
import junit.framework.TestCase;
public class IsStringEmpty extends TestCase {
//效率第三
public void testXiaolv1()
{
String str1 = "chenchaoyang";
Long satrt = System.currentTimeMillis();
System.out.println(satrt);
if(str1 != null && !str1.equals(""))
{
System.out.println("chenchaoyang");
System.out.println("chenchaoyang");
System.out.println("chenchaoyang");
System.out.println("chenchaoyang");
}
Long end = System.currentTimeMillis();
System.out.println(end);
System.out.println(satrt - end);
}
//效率第二
public void testXiaolv2()
{
String str1 = "chenchaoyang";
Long satrt = System.currentTimeMillis();
System.out.println(satrt);
if(str1 != null && !str1.isEmpty())
{
System.out.println("chenchaoyang");
System.out.println("chenchaoyang");
System.out.println("chenchaoyang");
System.out.println("chenchaoyang");
}
Long end = System.currentTimeMillis();
System.out.println(end);
System.out.println(satrt - end);
}
//效率最高
public void testXiaolv3()
{
String str1 = "chenchaoyang";
Long satrt = System.currentTimeMillis();
System.out.println(satrt);
if(str1 != null && str1.length() > 0)
{
System.out.println("chenchaoyang");
System.out.println("chenchaoyang");
System.out.println("chenchaoyang");
System.out.println("chenchaoyang");
}
Long end = System.currentTimeMillis();
System.out.println(end);
System.out.println(satrt - end);
}
}
分享到:
2014-04-09 23:16
浏览 1204
评论
更多推荐
java string 效率
发布评论