0

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

1
  • 1
    Please put more effort into formatting your code - and ideally, using conventional Java capitalization. The more readable the code in your question is, the more likely you are to get an answer. Commented Mar 3, 2015 at 15:25

2 Answers 2

2

listcashmessage1.get(0) will return the object stored in the list at index 0. Call listcashmessage1.get(i).yourGetter() to get the actual value.

Sign up to request clarification or add additional context in comments.

Comments

1

You can use a for-each loop:

for (eurrexcashMessageObject emo : listcashmessage1) {
  String paymentDate = emo.getPaymentDate();
  //etc.
}

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.