你真的知道isEmpty 和 isBlank ?

2021-10-10 14:51:36 字數 819 閱讀 9292

org.apache.commons.lang.stringutils類提供了 string 的常用操作,最為常用的判空有如下兩種isempty(string str)isblank(string str)

原始碼如下

public static boolean isempty(string str) 

public static boolean isnotempty(string str)

public static boolean isblank(string str)

}return true;

} else

}public static boolean isnotblank(string str)

可以看到:

stringutils.isempty(string str)判斷某字串是否為空,為空的標準是str==nullstr.length()==0

stringutils.isblank(string str)判斷某字串是否為空或長度為 0 或由空白符 (whitespace) 構成

stringutils.isnotempty(string str)等價於!isempty(string str)

stringutils.isblank(string str)來執行判空操作,因為判斷的條件更多更具體,特別是進行引數校驗時;

你真的知道敏捷和迭代嗎?

迭代開發流程 什麼叫迭代開發?在迭代開發中,整個開發工作被組織為一系列的短小的 固定長度 如3周 的小專案,被稱為一系列的迭代,這叫迭代開發。每一次迭代都包括了定義 需求分析 設計 實現與測試。而敏捷開發是以使用者的需求進化為核心,採用迭代 循序漸進的方法進行軟體開發。前者是軟體開發的生命週期模型,...

你真的知道 strtotime 嗎?

課堂小提問 echo date y m d strtotime 1 month strtotime 2017 03 31 輸出什麼?echo date y m d strtotime 1 month strtotime 2017 08 31 輸出又是什麼?現在公布正確答案了 echo date y ...

你真的知道HTML嗎?

經過幾次面試當中,被問及到最基礎的東西,沒想到回答不上來,有點蛋痛,今天特地的複習了一下!內容 1.doctype 文件型別 的作用是什麼?有多少文件型別?2.瀏覽器標準模式和怪異模式之間的區別是什麼?3.html dhtml xhtml是什麼?以及它們的區別是什麼?一 doctype 文件型別 的...