如何在每次將值「添加」到largeAttributeList
?時清空attributeList
。我試過.clear(),但是然後largeAttributeList失去了所有的值。清空循環中的數組列表
ArrayList<String> attributeList = new ArrayList<String>();
ArrayList<ArrayList<String>> largeAttributeList = new
ArrayList<ArrayList<String>>();
for (int i = 0; i < attribute.getLength(); i++) {
String current = attribute.item(i).getTextContent();
if(current.equals("Identifier")){
largeAttributeList.add(attributeList);
}
else{
attributeList.add(current);
}
}
您的輸入與期望輸出的示例? –