我想遍历数组列表。我也确实想更改列表的每次迭代的value
。例如:
for (int i = 0; i < value.length; i++) {
System.out.println(i+1, list.value[i]);
}
我的value
数组如下所示:
String [] value = {"identifier", "hyperlink", "children", "afterItemList", "beforeItemList"};
列表声明:
public class ItemAndAttributeObject {
String hyperlink;
String identifier;
String title;
String parentUniqueUrl;
String functionType;
ArrayList<String> children;
ArrayList<String> attributeList;
ArrayList<String> afterItemList;
ArrayList<String> beforeItemList;
public ItemAndAttributeObject(String title, String identifier, String hyperlink, String parentUniqueUrl, String functionType, ArrayList<String> children, ArrayList<String> attributeList, ArrayList<String> afterItemList, ArrayList<String> beforeItemList) {
this.hyperlink = hyperlink;
this.identifier = identifier;
this.title = title;
this.children = children;
this.functionType = functionType;
this.parentUniqueUrl = parentUniqueUrl;
this.attributeList = attributeList;
this.afterItemList = afterItemList;
this.beforeItemList = beforeItemList;
}
我想:
像这样打印出来:
//FIRST ITTERATION
for (int i = 0; i < value.length; i++) {
System.out.println(i+1, list.identifier);
}
//SECOND ITTERATION
for (int i = 0; i < value.length; i++) {
System.out.println(i+1, list.hyperlink);
}
//THIRD ITTERATION
for (int i = 0; i < value.length; i++) {
System.out.println(i+1, list.children);
}
//FOURTH ITTERATION
for (int i = 0; i < value.length; i++) {
System.out.println(i+1, list.afterItemList);
}
这可能吗?
答案 0 :(得分:-2)
for (int i = 0; i < value.length; i++) {
System.out.println(list.value[i]);
value[i] = "new";
}
尝试