gpt4 book ai didi

java - 字符串或字符串缓冲区

转载 作者:行者123 更新时间:2023-12-01 01:07:23 25 4
gpt4 key购买 nike

private void doShareEmp(pageBean UTIL, HttpServletRequest request, String page)
throws Exception
{
doAction(request, UTIL, page);
String action = pageBean.getSafeRequestOrNullParameter(request, "DO");
long empRecNum = UTIL.getNumValue("EMPLOYEE", "REC_NUM");
if (action != null)
{
if (action.startsWith("US:"))
unshareEmployee(request, UTIL, action.substring(3));
else if (action.equals("SHARE") && empRecNum != 0)
shareEmployee(request, UTIL, empRecNum);
}
ListBean list = UTIL.getListBean(request, "EMPSHARELIST", true);
if (empRecNum != 0)
{
StringBuffer sql = new StringBuffer();
sql.append("SELECT FLDREC_NUM, FLDCOMPANY, FLDLOCATION, FLDDEPT FROM @SCHEMAEMPLVIEW WHERE FLDEMPLOYEE = ? AND FLDTABLE='SHARED' ORDER BY FLDCOMPANY, FLDLOCATION, FLDDEPT");
ArrayList qryParms = new ArrayList();
qryParms.add(new Long(empRecNum));
list.setQuery(UTIL, sql, qryParms);
}
else
list.init();
}

在这段代码中,我将查询附加到 StringBuffer。

哪个会更好?

  1. 字符串
  2. 字符串缓冲区
  3. 字符串生成器

最佳答案

自 1.5 以来,

StringBuilder 是单线程环境中 StringBuffer 的替代品,因此请使用 StringBuilder。如果事后您不打算对数据进行任何其他操作,请使用 String

关于java - 字符串或字符串缓冲区,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3963088/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com