Q:

ArrayList values set to last value after exiting for loop

I have a method that is supposed to create a List of Name Objects from a dataset which contains a name and 11 ints representing the popularity of the name through the decades.
Example of data:
Zelda 436 420 468 526 789 961 938 0 0 0 0
Zulma 0 0 0 0 0 0 837 0 0 0 0

Currently the dataset is read in correctly and when I check the Name objects from within the for loop everything is correct.
But after the for loop exits, all values within the ArrayList have the same popularity values as the last entry, while name values remain correct.
What should happen:
Zelda 436 420 468 526 789 961 938 0 0 0 0
Zelda [436, 420, 468, 526, 789, 961, 938, 0, 0, 0, 0]

What actually happens:
Zelda 436 420 468 526 789 961 938 0 0 0 0
Zelda [0, 0, 0, 0, 0, 0, 837, 0, 0, 0, 0]

Data and output of last entry:
Zulma 0 0 0 0 0 0 837 0 0 0 0
Zulma [0, 0, 0, 0, 0, 0, 837, 0, 0, 0, 0]

Code:
public static ArrayList<Name> createNameArray(String[] data) {

    int nameLength;
    String name;
    String pops;
    ArrayList<Name> names = new ArrayList<Name>();
    int[] popsInts = new int[11];

    for (int i = 0; i < data.length; i++) {

        // Checking data array, no missing data here
        System.out.println(data[i]); //returns correctly
        nameLength = data[i].indexOf(' ');

        name = data[i].substring(0, nameLength);
        pops = data[i].substring(nameLength + 1);

        for (int k = 0; k < 11; k++) {
            popsInts[k] = Integer.parseInt(pops.split(" ")[k]);
        }

        names.add(new Name(name, popsInts));

        // Checking if Name object added to names is correct which it always is
        System.out.println(names.get(i)); //returns correctly

    }

    // If I print out values of the ArrayList here, everything is wrong
    return names;

}

How I am calling from the main method:
ArrayList<Name> list = createNameArray(data);
// Printing out ArrayList, all values are wrong except last one
// Using a regular for loop produces same results
for(Name n : list) { 
    System.out.println(n);
}

I have tried using a Name[] but the same thing happens.
What am I doing wrong, and what can I do to fix the error?

A:

The problem is that your Name class is probably something defines as
class Name {
  String name;  
  int[] popsInt;

  Name(String name, int[] popsInt) {
    this.name = name;
    this.popsInt = popsInt)
  }
}

So you are storing a reference to an int[] inside Name instance. But the array you pass to the constructor is just one and it's constructed outside the loop that parses all the data:
int popsInt = new int[11];
for (each game) {
  popsInt = parse data
  list.add(new Name(name, popsInt));
}

So you construct a Name by passing a reference always to the same array, so in the end they all point to the same set of 11 values.
You must either copy the data passed or allocate a new array on each call, eg:
for (each game) {
  int[] popsInt = new int[11];
  popsInt = parse data;
  list.add(new Name(name, popsInt));
}

Now each Name instance gets its own array.

