Okay so I have this two Lists called idadults and adults, I also have two String[] arrays called infoAdults (of size 255) and adultsID (of size 1). The code I have makes infoAdults read the information from a CSV file and adds that information to the adults list. It also checks if any value/box is missing, and changes its value to "9999". On column #15 in the CSV file, there's the id of each Adult, but some of them are missing. adultsID grabs each value of the column and then adds it to the idadults list. The code also first checks if that value exists, and if not it changes it to "9999" again. My problem is that when I print the adults list it prints everything correctly like it should be, but when I try to print the idadults list it only prints the last value in the column over and over again n times, n being the size of the column. I already tried removing the "static" part when I define both of my Lists, but it didn't work. I also already tried to print adultsID[0] individually, and they all print correctly. What do?
public String[] adultsID = new String[1];
public static List<String[]> idadults = new ArrayList<String[]>();
public static String csvFile = userDir + "/Adults.csv";
public String[] infoAdults = new String[255];
public static List<String[]> adults = new ArrayList<String[]>();
try {
br = new BufferedReader(new FileReader(csvFile));
while ((line = br.readLine()) != null) {
infoAdults = line.split(csvSplitBy);
for(int i=0;i<infoAdults.length;i++){
if(infoAdults[i].isEmpty()){
infoAdults[i]="9999";
}
if(i>16){
adultsID[0]=infoAdults[16];
}
else{
adultsID[0]="9999";
}
}
idadults.add(adultsID);
adults.add(infoAdults);
}
for (String[] strings : idadults) {
System.out.println(Arrays.toString(strings));
}
}