StringUtils.java:
package com.yx.equipment_collection.utils;

import android.annotation.SuppressLint;
import android.text.TextUtils;
import android.util.Log; /**
*
* 此类描述的是: String帮助类
*
* @author: CS YX
* @version:1.0
* @date:2014-10-21 下午2:47:08
*/
public class StringUtils {
private static final String TAG = "StringUtils";
private static int count = ; public static void checkEmpty1(String str) {
long start = System.currentTimeMillis();
for (int i = ; i < count; i++) {
if (str == null || str.length() < ) {
}
}
long end = System.currentTimeMillis();
Log.i(TAG, "checkEmpty1 --- " + (end - start));
} @SuppressLint("NewApi")
public static void checkEmpty2(String str) {
long start = System.currentTimeMillis();
for (int i = ; i < count; i++) {
if (str == null || str.isEmpty()) {
}
}
long end = System.currentTimeMillis();
Log.i(TAG, "checkEmpty2 --- " + (end - start));
} public static void checkEmpty3(String str) {
long start = System.currentTimeMillis();
for (int i = ; i < count; i++) {
if (str == null || str == "") {
}
}
long end = System.currentTimeMillis();
Log.i(TAG, "checkEmpty3 --- " + (end - start));
} public static void checkEmpty4(String str) {
long start = System.currentTimeMillis();
for (int i = ; i < count; i++) {
if (str == null || str.equals("")) {
}
}
long end = System.currentTimeMillis();
Log.i(TAG, "checkEmpty4 --- " + (end - start)); } public static void checkEmpty5(String str) {
long start = System.currentTimeMillis();
for (int i = ; i < count; i++) {
if (str == null || TextUtils.isEmpty(str)) {
}
}
long end = System.currentTimeMillis();
Log.i(TAG, "checkEmpty5 --- " + (end - start)); } public static void checkEmpty11(String str) {
long start = System.currentTimeMillis();
for (int i = ; i < count; i++) {
if (str != null && str.length() > ) {
}
}
long end = System.currentTimeMillis();
Log.i(TAG, "checkEmpty11 --- " + (end - start));
} @SuppressLint("NewApi")
public static void checkEmpty22(String str) {
long start = System.currentTimeMillis();
for (int i = ; i < count; i++) {
if (str != null && !str.isEmpty()) {
}
}
long end = System.currentTimeMillis();
Log.i(TAG, "checkEmpty22 --- " + (end - start));
} public static void checkEmpty33(String str) {
long start = System.currentTimeMillis();
for (int i = ; i < count; i++) {
if (str != null && str != "") {
}
}
long end = System.currentTimeMillis();
Log.i(TAG, "checkEmpty33 --- " + (end - start));
} public static void checkEmpty44(String str) {
long start = System.currentTimeMillis();
for (int i = ; i < count; i++) {
if (str != null && !str.equals("")) {
}
}
long end = System.currentTimeMillis();
Log.i(TAG, "checkEmpty44 --- " + (end - start)); } public static void checkEmpty55(String str) {
long start = System.currentTimeMillis();
for (int i = ; i < count; i++) {
if (str != null && !TextUtils.isEmpty(str)) {
}
}
long end = System.currentTimeMillis();
Log.i(TAG, "checkEmpty55 --- " + (end - start)); } }

Android比较字符串是否为空(isEmpty)的更多相关文章

  1. Android 判断字符串是否为空

    TextUtils.isEmpty(str) 可以判断字符串是否为null或者"",当是的时候为true,否的时候为false

  2. android 判断字符串是否为空与比对["=="与equals()的区别]

    if (s == null || s.equals("")) ; } s.equals("")里面是要比对的字符串 声明字符串未赋初始值或值,然后比对就会出错, ...

  3. java判断一个字符串是否为空,isEmpty和isBlank的区别

    转载于:https://blog.csdn.net/liusa825983081/article/details/78246792 实际应用中,经常会用到判断字符串是否为空的逻辑 比较简单的就是用 S ...

  4. 【代码笔记】iOS-判断字符串是否为空

    一,代码. - (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view. ...

  5. C# 中如何判断某个字符串是否为空的方法

    C# 中如何判断某个字符串是否为空的方法 分享了三个方法来判断字符串是否为空 引自:http://www.itokit.com/2012/0724/74618.html 1. 三种常用的字符串判空串方 ...

  6. StringUtils判断字符串是否为空的方法

    public static boolean isEmpty(String str)   判断某字符串是否为空,为空的标准是 str==null 或 str.length()==0   下面是 Stri ...

  7. java如何判断字符串是否为空的方法

    以下是java 判断字符串是否为空的四种方法: 方法一: 最多人使用的一个方法, 直观, 方便, 但效率很低: if(s == null ||"".equals(s)); 方法二: ...

  8. Java空字符串与null的区别和判断字符串是否为空的方法

    Java空字符串与null的区别: 1.类型null表示的是一个对象的值,而并不是一个字符串.例如声明一个对象的引用,String a = null ;""表示的是一个空字符串,也 ...

  9. Js判断对象是否为空,Js判断字符串是否为空

    Js判断对象是否为空,Js判断字符串是否为空,JS检查字符串是否为空字符串 >>>>>>>>>>>>>>>&g ...

随机推荐

  1. Android 网络编程与通信协议

    大多数的Android应用程序都会使用HTTP协议来发送和接收网络数据,而Android中主要提供了两种方式来进行HTTP操作, HttpURLConnection和HttpClient.这两种方式都 ...

  2. SVN Git 设置忽略目录 大全

    eclipse中SVN设置 用svn控制版本,svn本身是不会识别哪些该传,哪些不该传,这就导致有些关于路径的东西(比如拓展jar的路径)也被上传了,而当别人下载后,那个路径对于这个人可能完全不存在, ...

  3. 使用URL读取网络图片资源

    URL(Uniform Resource Locator) 对象代表统一资源定位器. 代码如下: public class MainActivity extends ActionBarActivity ...

  4. android 瀑布流(图片浏览)

    效果图: 瀑流流实现涉及的知识点 1.ScrollView滚动视图,我们这里用的是自定义ScrollView /** * Created by Spring on 2015/11/2. * 自定义Sc ...

  5. c 单链表反转(不添加新结点空间)

    最近复习考研,加上一直都将"算法"放在很高的位置,所以,蛮重视算法的.不多说了,其实这个问题,不难理解的. 主要代码: //反转单链表. void reverse(linklist ...

  6. [c#]asp.net开发微信公众平台(1)数据库设计

    开发微信公众平台之前,先去微信官方了解下大概的情况 这里:http://mp.weixin.qq.com/wiki/index.php :看了之后心里大致有数了,开始设计数据库,尽可能的考虑,未考虑到 ...

  7. share js 分享代码

    (function(){ var $doc = $(document); var shareHandlers = { 'twitter': function(prop,shareUrl){ var D ...

  8. HADOOP报错Incompatible namespaceIDs

    出现这个问题的原因是因为namespaceIDs导致的 解决方案1<推荐> 1. 进入链接不上的从机 stop-all.sh关闭hadoop 2. 编辑namespaceID,路径是< ...

  9. iOS9中通过UIStackView实现类似大众点评中的效果图

    效果图如下: 实现思路 整体可以看做为一个大的UIStackView(排列方式水平)包括一个子UIStackView(排列方式垂直),其中左边包括一个图片,右边的UIStackView中可以看做包括三 ...

  10. JAVA-5-关于for循环的几个例子

    打印一个*组成的矩形 public static void main(String[] args) { // TODO 自动生成的方法存根 for (int i = 0; i < 5; i++) ...