shaki mandira
shaki mandira

Reputation: 299

set array values in to a text area in java

i want to set an array list value in to a text area. this is my code,

ArrayList<String> phone_numberArray = db.getNumberSms();

        for(int i=0; i<phone_numberArray.size(); i++){
          jtext_area.addElement(phone_numberArray.get(i));
        }

this code getting errors. some one help me please....

Upvotes: 1

Views: 4087

Answers (2)

oliholz
oliholz

Reputation: 7507

Try:

for(String number : db.getNumberSms()) {
    jtext_area.append(number);
}

Upvotes: 2

Jigar Joshi
Jigar Joshi

Reputation: 240948

I assume jtext_area is an instance of JTextArea , I don't see any addElement() in that class, You might be looking for append()

Upvotes: 2

Related Questions