Reputation: 301
I have the below pojo named eurrexcashMessageObject with corresponding setters and getters
public class eurrexcashMessageObject implements Cloneable{
private String PaymentDate;
private String CCPTradeId;
private String Currency;
private String Contract_Id;
private String PaymentAmount;
//include seeters & getters also
}
now there is a method in which i am retrieving the list
List<eurrexcashMessageObject> listcashmessage1 = eurexcashParsing.getcashmessageojects();
so as you can see that list which is retrieved is of eurrexcashMessageObject type now i am iterating over the list as shown below..
for(int i = 0; i < listcashmessage1.size(); i++)
{
String PaymentDate = String.valueOf(listcashmessage1.get(0));
String CCPTradeId = String.valueOf(listcashmessage1.get(1));
String Currency = String.valueOf(listcashmessage1.get(2));
String Contract_Id = String.valueOf(listcashmessage1.get(3));
String PaymentAmount = String.valueOf(listcashmessage1.get(4));
now i can see that in variable PaymentDate the string is not store and similar is the case for CCPTradeId,Currency,Contract_Id,PaymentAmount can you please advise how can i convert the list contents into string within for loop
Upvotes: 0
Views: 39
Reputation: 328608
You can use a for-each loop:
for (eurrexcashMessageObject emo : listcashmessage1) {
String paymentDate = emo.getPaymentDate();
//etc.
}
Upvotes: 1
Reputation: 11944
listcashmessage1.get(0)
will return the object stored in the list at index 0. Call listcashmessage1.get(i).yourGetter()
to get the actual value.
Upvotes: 2