Search code examples
javaarraylistjtextfield

Display Text From ArrayList


I'm trying to display data that I have stored in an ArrayList into JtextField. for example I would like to get the (ID,Name,Age,Gender) at point 0 in the array and display them into JtextFields.

I have tried the code below but it does not work as expected:

for (int i = 0; i < GPSDataEnter.size(); i++) {
    LatTextData.append((String) GPSDataEnter.get(i));
}

Solution

  • Try this:

    string ArrayData = string.Empty;
        ArrayList listData = new ArrayList();
            foreach (string textItem in listData)
    
            {
    
            ArrayData = ArrayData + ", " + textItem;
    
            }
    
       textBox1.setText(ArrayData);