-8

How do I get a specific item out of a "List" at a specific index?

private List<String[]> rows;
iTz_ElKay
  • 31
  • 6

3 Answers3

2

You have to use get(i) with the list and [j] for array :

String value = rows.get(i)[j];

In your case rows.get(i) return a String[], then [j] will return a String with the index j.


For more details, I will invite you to learn about :

YCF_L
  • 51,266
  • 13
  • 85
  • 129
2

RTFM for the List class

All the methods are listed and explained there, e.g.: get(int):

Returns the element at the specified position in this list.

Also recommended: The Java™ Tutorials

user85421
  • 28,490
  • 10
  • 64
  • 86
0

Simply use a enhanced for loop to get items

for (String row: rows) {
    //  do what you want

    // ...
}
aselsiriwardena
  • 423
  • 4
  • 24