My problem: Use an Iterator to go through all of the elements in the list, getting each element's textual representation, and displaying this text neatly inside the text area.

My thoughts: Do I use an add method to add elements from the list to display onto the text area?

No, you do exactly what the assignment indicates: Use an Iterator (look it up in the API) to walk through each List element and append the String from each element's toString() value to your text area.

but the list elements are in a txt file how can I walk through it ?


thanks

Well, that is another operation which you did not mention in your original post. A List is not the same thing as a text file. If you need to first place those entries in a List, then you will need to open a BufferedReader against the file, load each entry into a List (ArrayList most likely), and then use the Iterator to walk that list and append the items to the text area.

If the assignement is as you state, then surely you have some course notes covering some of these operations, which you can use as a starting point for your own code.

how do I call "append" ? Can you give me some examples

I was not referring to a specific method - only a general outline of the steps. Please post your code and specific questions if you need more help beyond general advice.

this is the method need to use an iterator...

// YOU MUST ADD CODE TO THIS METHOD SUCH THAT WHEN CALLED IT
// NEATLY DISPLAYS ALL INFORMATION CONTAINED IN THE WebSite LIST
// YOU SHOULD USE AN ITERATOR TO GET THE DATA
public void updateTextArea()
{
// DEFINE YOUR CODE HERE
}

Edited 3 Years Ago by happygeek: fixed formatting

This article has been dead for over six months. Start a new discussion instead.