From 20b0bba8444fce7377919c7a2a3d33755494918d Mon Sep 17 00:00:00 2001 From: qi_liang Date: Fri, 10 Jan 2020 23:43:57 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=AD=97=E7=AC=A6=E4=B8=B2?= =?UTF-8?q?=E5=88=A4=E6=96=ADnull?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/org/panda/code/uitl/StringUtil.java | 22 ++++++++++--------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/panda-code/src/main/java/org/panda/code/uitl/StringUtil.java b/panda-code/src/main/java/org/panda/code/uitl/StringUtil.java index a200741..9e52949 100644 --- a/panda-code/src/main/java/org/panda/code/uitl/StringUtil.java +++ b/panda-code/src/main/java/org/panda/code/uitl/StringUtil.java @@ -19,7 +19,8 @@ public class StringUtil { * @return */ public static boolean isEqual(String str1,String str2){ - if (isNull(str1)||isNull(str2)){ + + if (isEmpty(str1)||isEmpty(str2)){ return false; } return str1.equals(str2); @@ -30,15 +31,9 @@ public class StringUtil { * @param str1 * @return 为空返回true */ - public static boolean isNull(String str1){ + public static boolean isEmpty(String str1){ - if (str1==null){ - return true; - } - if (str1 == ""||"".equals(str1)){ - return true; - } - return false; + return str1==null||str1.length()==0; } /** @@ -48,7 +43,7 @@ public class StringUtil { */ public static boolean isNotNull(String str1){ - return !isNull(str1); + return !isEmpty(str1); } /** @@ -143,5 +138,12 @@ public class StringUtil { return null; } + public static void main(String[] args) { + + String text = "你好[xxxxx]"; + System.out.println(text.indexOf("[")); + + } + }