首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > 其他数据库 >

findBugs提醒Dead store to local variable

2012-06-27 
findBugs提示Dead store to local variablepublic static String toGridJSONString(List objectList, Stri

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();是没有必要的。这样会消耗资源。

热点排行