我有以下代码eclipse为什么说局部变量即使被使用也不被使用?
private List<String> getItems() {
XmlDoc document = new XmlDoc();
List<String> itemList = new ArrayList<String>();
String itemNum;
try {
XmlUtils root = document.parse(xmlFile);
List<XmlUtils> listNode = root.getChildNodes();
for (XmlUtils node : listNode) {
itemNum = node.getValue();
}
} catch (XmlException e) {
e.printStackTrace();
}
return itemList;
}
即使我使用的字符串itemNum里面的for循环日食说“局部变量itemNum的值不使用”。为什么?
你在哪里使用它?你认为分配有什么效果? – 2015-04-03 15:10:39
我在String itemNum处看到它; – 2015-04-03 15:11:12