Java 如何迭代2个数组列表

Java 如何迭代2个数组列表,java,list,Java,List,我有一个java对象包含一个以上的对象 public class ParameterValue { private Property property; private String PropertyValue; public static class Property { private String paramNa

我有一个java对象包含一个以上的对象

public class ParameterValue {            
        private Property property;            
        private String PropertyValue;            
        public static class Property {               
               private String paramName;        
        }
}
在我的util方法中,我获取列表中的所有属性名

 List<ParameterValue.Property> properties=   getAllParameter();    
 List<ParameterValue> paramValues= getAllParameterValues();
List properties=getAllParameter();
List paramValues=getAllParameterValues();
它只返回我
ParameterValue
objets只设置值


现在我想从properties列表中获取Property对象,并在paramvalues列表中设置,创建一个完整的对象。我该怎么做呢。如果
properties
列表中索引
N
处的相应条目对应于
paramValues
列表中的相同索引
N
,是否可以迭代两个列表

//断言properties.size()==paramValues.size();
对于(int idx=0,size=properties.size();idx
使用标准forloop:

for (int i = 0; i < properties.size(); i++) {
  properties.get(i); //get the ParameterValue.Property
  paramValues.get(i); //get the ParmeterValue
}
for(int i=0;i
上下文有点不清楚,但您最好使用
java.util.Map
,将
ParameterValue.Property
映射到
ParamaterValue
s。您的问题实际上不是很清楚。。你能详细说明一下你想要实现什么吗?我从一个方法中获取内部对象1作为列表,从另一个方法中获取外部对象2 fr m,其中只设置字符串值。我想将对象1注入对象2如何设置它我可以从循环内的计数器中获取一个对象来设置如何进行?我可以获取对象,但我想使用内部对象和我从2个独立的methods@constantlearner,答案说明了如何访问元素。如果您需要更新
ParameterValue
实例,请使用一些
public
方法来允许(问题中发布的代码没有显示任何内容)。感谢您的输入,我有获取对象的逻辑,但如何设置它while(){和for loop inside}我有获取对象的逻辑,但我想将属性注入param value对象
for (int i = 0; i < properties.size(); i++) {
  properties.get(i); //get the ParameterValue.Property
  paramValues.get(i); //get the ParmeterValue
}