-8

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

private List<String[]> rows;
iTz_ElKay
  • 41
  • 7

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 :

Youcef LAIDANI
  • 55,661
  • 15
  • 90
  • 140
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,957
  • 10
  • 64
  • 87
0

Simply use a enhanced for loop to get items

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

    // ...
}
R0b1n
  • 513
  • 1
  • 5
  • 28