Reputation: 32331
I am extracting an array of data and setting those data inside an Object in Java .
I don't know, after getting the data from an array, how can I set this into an Object ??
please have a look at the code below:
public class Legform implements Serializable {
private SecurityType securityType;
public SecurityType getSecurityType() {
return securityType;
}
// As well as a setter Method also present
}
I am extracting this LegForm Object (the above one) here as shown from another java class :
Legform[] legdata = orderform.getLeg();
After looping throught this data, I need to set them inside another object called Leg (a Java class)
for(int i = 0; i < legdata.length; i++) {
System.out.println(legdata[i].getSecurityType());
// Here do i need to set the data into the Leg Object
}
I need to set this extracted information to a Leg Object The Leg Object is shown below :
public class Leg
{
public String securityType;
}
could anybody help me please?
Upvotes: 0
Views: 98
Reputation: 262714
List<Leg> legs = new ArrayList<Leg>(legdata.length);
for (Legform ld: legdata){
Leg leg = new Leg();
leg.securityType = ld.getSecurityType();
legs.add(leg);
}
Upvotes: 2