Tips: List<String> to String[]

List to String[] skills

Demand generation scenario

Sometimes in the process of using mybatis, the xml file defines the elements in the String array to be read in a loop, so the list is converted to String[] for parameter passing.

Code example

public int updateHandleState(String handleState, List<String> applyIds) {
    
    
    if (!StringUtils.isEmpty(handleState) && null != applyIds && !applyIds.isEmpty()) {
    
    
    	//下面就是list<String>转String[]的写法
        String[] applyIdStr = applyIds.toArray(new String[applyIds.size()]);
        return mattersApplyDao.updateHandleState(handleState,applyIdStr);
    }
    return 0;
}

Guess you like

Origin blog.csdn.net/rao991207823/article/details/107881047