Non-empty judgment

String String

String id= null == request.getParameter("id") ? "" : request.getParameter("id").toString();

if(null != id && !id.equalse("")){
    //不为空
}

import org.apache.commons.lang3.StringUtils;
if(StringUtils.isNotEmpty(id)){
    //不为空
}

Integer

null != Integer ;

Objects

null != object

List collection

IF (null! = && list.size List ()> 0) { 
 
} 

list.isEmpty () and list.size () == 0 no difference

Map collection

IF (null! && map.size Map = ()> 0) { 
// is not empty 
}

JavaScript

actiName $ = var ( '# ACTIVITY_NAME') Val ();. 
. TRIM // $ () function will be removed at the beginning and end of a string of all line feed, space (including consecutive spaces) and tabs. If these whitespace characters in the middle of the string, they will be retained and will not be removed. 
IF (actiName == null || '' == $ .trim (actiName)) { 
    Alert ( 'Enter event name!'); 
    return to false; 
} 

// equal determined 
if (activity_type == '1') { 

}

 

Guess you like

Origin www.cnblogs.com/zybcn/p/11315097.html