Android比较字符串是否为空(isEmpty)
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)的更多相关文章
- Android 判断字符串是否为空
TextUtils.isEmpty(str) 可以判断字符串是否为null或者"",当是的时候为true,否的时候为false
- android 判断字符串是否为空与比对["=="与equals()的区别]
if (s == null || s.equals("")) ; } s.equals("")里面是要比对的字符串 声明字符串未赋初始值或值,然后比对就会出错, ...
- java判断一个字符串是否为空,isEmpty和isBlank的区别
转载于:https://blog.csdn.net/liusa825983081/article/details/78246792 实际应用中,经常会用到判断字符串是否为空的逻辑 比较简单的就是用 S ...
- 【代码笔记】iOS-判断字符串是否为空
一,代码. - (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view. ...
- C# 中如何判断某个字符串是否为空的方法
C# 中如何判断某个字符串是否为空的方法 分享了三个方法来判断字符串是否为空 引自:http://www.itokit.com/2012/0724/74618.html 1. 三种常用的字符串判空串方 ...
- StringUtils判断字符串是否为空的方法
public static boolean isEmpty(String str) 判断某字符串是否为空,为空的标准是 str==null 或 str.length()==0 下面是 Stri ...
- java如何判断字符串是否为空的方法
以下是java 判断字符串是否为空的四种方法: 方法一: 最多人使用的一个方法, 直观, 方便, 但效率很低: if(s == null ||"".equals(s)); 方法二: ...
- Java空字符串与null的区别和判断字符串是否为空的方法
Java空字符串与null的区别: 1.类型null表示的是一个对象的值,而并不是一个字符串.例如声明一个对象的引用,String a = null ;""表示的是一个空字符串,也 ...
- Js判断对象是否为空,Js判断字符串是否为空
Js判断对象是否为空,Js判断字符串是否为空,JS检查字符串是否为空字符串 >>>>>>>>>>>>>>>&g ...
随机推荐
- WORLD OPERATS
word文章设置无法复制 通常我们会采用设置密码的方式,规定某个文档的使用范围. 但这种方法是有一个局限,那就是可以观看文档的人未必靠谱,万一复制了文档的重要内容怎么办? 因此,不妨考虑加上禁 ...
- 第二节,CCSpriteBatchNode CCSpriteFrameCache
1,CCSpriteBatchNode 精灵集合类 其中Batch的英文含义是一批,一群的意思.他的对象常常包含了许多的精灵对象,这些精灵对象有一个共同的特点,那就是使用同一张文理图片.虽然是同一个纹 ...
- Android组件系列----BroadcastReceiver广播接收器
[声明] 欢迎转载,但请保留文章原始出处→_→ 生命壹号:http://www.cnblogs.com/smyhvae/ 文章来源:http://www.cnblogs.com/smyhvae/p/3 ...
- dp 斯特林数 HDU2512一卡通大冒险
这道题其实就是斯特林数,找不同的集合,一共有多少中组法,递推式就是dp[n][k] = dp[n - 1][k - 1] + k * dp[n - 1][k]; 这个式子可以这么解释,dp[n][k] ...
- ios 中如何应对UIScrollView快速滑动(暴力用户,暴力测试)
1.实现UIScrollViewDelegate 开始滑动: - (void)scrollViewWillBeginDecelerating:(UIScrollView *)scrollView 滑动 ...
- Oracle数据库配置方式二--使用Net Manager配置数据库
在Oracle安装配置中使用Net Configuration配置了数据库,今天给大家介绍第二种配置方式,Net Manager配置. 先找到我们的Net Manager的快捷方式,如下面截图
- http方式的联调经验
这近在做一个项目,现在刚与厂家做联调.我的系统是windows2008,他的测试机是unix,他本机是XP的.本来用httppost方式给他本机发送中文数据是正常的,但是发送到他的unix上,中文就变 ...
- gc内存回收机制
判断哪些对象可回收 GC是通过对象是否存活来决定是否进行回收,判断对象是否存活主要有两种算法:引用计数算法.可达性分析算法 引用计数算法 引用计数的算法原理是给对象添加一个引用计数器,每被引用一次计数 ...
- windows下安装apache笔记
之前一直是用别人配置好的apache环境来开放,今天想自己安装配置下windows下的apache(nginx+fastcgi).mysql.php等. 虽然大部分时间是在搞前端开发,偶尔也要搞服务端 ...
- jquery获取浏览器高度、宽度和滚动条高度(来自网络)
Jquery代码: alert($(window).height()); //浏览器时下窗口可视区域高度 alert($(document).height()); //浏览器时下窗口文档的高度 ale ...