Is there a standard approach, can put the null, an empty string (" ", ""," ", etc.), is to "empty string"?
CodePudding user response:
1, if you are using maven, rely on the package org.apache.com mons: Commons - lang3 version is 3.6 (it doesn't matter), maven reliedIf not using maven download this package directly to the local
2, and then you can directly use the
String STR is empty: no StringUtils. IsNotBlank (STR) :
Determine the string STR is empty: StringUtils. IsBlank (STR) :
CodePudding user response:
Judge empty string use "" equals (XXXX), can avoid a null pointer, as for the way you said, the JDK does not provide, you can write a utility class methods, implementation is simpleCodePudding user response:
Comparing equals the content is same, null and ", "==compare the address values, these two methods is null or" "is not equal