StringBuffer在循环中拼接字符串

        //获取之前处理人的邮件列表

        List activityList = flowInstance.getActivityList();
        StringBuffer dealUserMail = new StringBuffer();
        if (activityList == null)
        {
            dealUserMail = new StringBuffer("");
        }
        else
        {
            for (TFlowActivity flowActivity : activityList)
            {
                dealUserMail = dealUserMail.append(flowActivity.getAuditEmail()).append(";");
            }
        }
        String dealUserMailList = dealUserMail.toString();

 

    在循环中拼接字符串最好使用StringBuffer,效率比String高很多。

你可能感兴趣的:(Java,Core)