【发布时间】:2015-04-03 15:09:56
【问题描述】:
我有以下代码
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;
}
即使我在 for 循环中使用了字符串 itemNum,eclipse 也会显示“未使用局部变量 itemNum 的值”。为什么会这样?
【问题讨论】:
-
你在哪里使用它?您认为分配有什么影响?
-
我在 String itemNum 看到它;