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. ubuntu14.04 安装

    summary: a). the way in the internet just a sugestion, I must to do it  in my own hands, yes ! just ...

  2. JAVA-1-学习历程1:基础知识1

     前言:此文属于个人学习中总结记录的较重要的知识点,分享一下.望对刚開始学习的人有点用. 视频04   语句.函数.数组 1.函数的重载 2.数组内存空间的划分 栈.堆 视频05    数组 1. ...

  3. Android 自定义View (二) 进阶

    转载请标明出处:http://blog.csdn.net/lmj623565791/article/details/24300125 继续自定义View之旅,前面已经介绍过一个自定义View的基础的例 ...

  4. 一个int类型究竟占多少个字节

    一个int占多少个字节? 这个问题我们往往得到的答案是4. 可是int究竟占多少个字节,却跟你的机器环境有关. As you can see, the typical data type sizes ...

  5. iText

    iText是著名的开放项目,是用于生成PDF文档的一个java类库.通过iText不仅可以生成PDF或rtf的文档,而且可以将XML.Html文件转化为PDF文件. 官方网站:http://itext ...

  6. HashSet内存泄露

    import java.util.HashSet; import java.util.Set; public class PersonTest { public static void main(St ...

  7. 【网络流#3】hdu 1532 - Dinic模板题

    输入为m,n表示m条边,n个结点 记下来m行,每行三个数,x,y,c表示x到y的边流量最大为c 这道题的模板来自于网络 http://blog.csdn.net/sprintfwater/articl ...

  8. 触摸事件 Touch MotionEvent ACTION

    MotionEvent简介 当用户触摸屏幕时,将创建一个MontionEvent对象,MotionEvent包含了关于发生触摸的位置.时间信息,以及触摸事件的其他细节. 获取MontionEvent对 ...

  9. 使用HighCharts实现实时数据展示

    在众多的工业控制系统领域常常会实时采集现场的温度.压力.扭矩等数据,这些数据对于监控人员进行现场态势感知.进行未来趋势预测具有重大指导价值.工程控制人员如果只是阅读海量的数据报表,对于现场整个态势的掌 ...

  10. nyoj 214

    //nyoj 214 这个题目和字符串的问题类似,都是给出一组数据,寻找最长的单调递增字符 这一题一开始我用dp做,发现超时,看了下时间,n*n的复杂度,换过一种思路 用类似于栈的方式,来存储每次更新 ...