Logo Questions Linux Laravel Mysql Ubuntu Git Menu

How do I reference an Array element in a List of Arrays?

I have created a LinkedList of String arrays:

public static void main(String[] args){

    String[] one = new String[10];
    String[] two = new String[10];
    String[] three = new String[10];

    LinkedList<String[]> myList = new LinkedList<String[]>();



My question is how do I now access an element of one of the arrays. For instance, I can access (or in the example print) the entire array element via:


But how do i access the first element in the String array that is owned by myList.get(0)? I tried everything like myList.get(0).[0], but I can't figure out how to access an element in an array, when the array is an element of a linked list.

like image 367
UFGator Avatar asked Mar 21 '23 10:03


1 Answers


That should do the trick.

array.get(0) returns an array, all you have to do is add your index after it (no dot to separate).

Just the same way you would use one[index].

like image 62
Jeroen Vannevel Avatar answered Apr 02 '23 10:04

Jeroen Vannevel