So every time I run the method test my String array is added to my ArrayList and it will print out the lyricLineInfo[4] value, but when the method test is ran again the array will be added on to the ArrayList but it will also replace all of the other ArrayList values with the new array. So when lyricLineInfo[4] is printed again it prints the new value instead of the old value like it's suppose to. I'm not sure why it's doing this can anyone help? Here is my code:
private String[] lyricLineInfo = new String[5];
private ArrayList<String[]> lyricLineNumber = new ArrayList<String[]>();
public void test() {
lyricLineNumber.add(getInfo());
System.out.println(lyricLineNumber.get(0)[4])
}
public String[] getInfo() {
if (chckbxLeadSinger.isSelected()) {
lyricLineInfo[0] = "true";
} else {
lyricLineInfo[0] = "false";
}
if (chckbxBackupSinger.isSelected()) {
lyricLineInfo[1] = "true";
} else {
lyricLineInfo[1] = "false";
}
lyricLineInfo[2] = fieldStartTime.getText();
lyricLineInfo[3] = fieldEndTime.getText();
lyricLineInfo[4] = fieldLyrics.getText();
return lyricLineInfo;
}