java string 效率

编程入门 行业动态 更新时间:2024-10-08 00:27:48

java string   <a href=https://www.elefans.com/category/jswz/34/1769807.html style=效率"/>

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 效率

本文发布于:2024-03-04 11:36:14,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1709167.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:效率   java   string

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!