How To Get Data From A Specific Arraylist Row Using With A Loop?
How do I get data from a specific ArrayList row using a loop? I've added those value into ArrayList as follow. myArrayList.add('ID007'); myArrayList.add('PPShein'); myArrayList.add
Solution 1:
ArrayList has a handy method called get
, which takes in an index. What you may be used to is using Arrays, such as array[3]
to access the 4th element. With an ArrayList, use the get method:
for(int i = 0; i < myArr.size(); i++) {
System.out.println(myArr.get(i)); //prints element i
}
Solution 2:
You just call the row...
String getName;
int rowValue = 2;
getName = myarr.get(rowValue);
Post a Comment for "How To Get Data From A Specific Arraylist Row Using With A Loop?"