Let cycle output string concatenation

Statement StringBuilder or StringBuffer

StringBuilder sb = new StringBuilder();

Append method further connected within the loop

for(int i=0;i<b.length;i++){
    String sqlId = '''select building_project_name
        from face_camera_info
        where building_project_id = ?'''
    String d = jdbcTemplate.queryForObject(sqlId,String.class,Integer.parseInt(b[i]))
    sb.append(d+',')
}

DeleteCharAt method can be used to delete the last comma outside the loop

sb.deleteCharAt(sb.length()-1)

ps: What is the problem exhibitions

Published 10 original articles · won praise 1 · views 3483

Guess you like

Origin blog.csdn.net/qq_31569787/article/details/89852077