读书人

findBugs提醒Dead store to local var

发布时间: 2012-06-27 14:20:09 作者: rapoo

findBugs提示Dead store to local variable

public static String toGridJSONString(List objectList, String attributes) {if (objectList == null)return null;if (objectList.size() == 0)return "";JSONArray arrayValue = new JSONArray();JSONObject oJson;try {arrayValue = toJSONArray(objectList, attributes,0);oJson = new JSONObject();oJson.put("totalPage", arrayValue.size());oJson.put("data", arrayValue);return oJson.toString();} catch (JSONException e) {e.printStackTrace();}return null;}

?系统提示?JSONArray arrayValue = new JSONArray();这行Dead store to local variable

是因为??arrayValue = toJSONArray(objectList, attributes,0);有重新实例化了对象arrayValue ,前一个 new JSONArray();是没有必要的。这样会消耗资源。

读书人网 >其他数据库

热点推荐