I'm trying to create a LinkedList of a custom class.
I've stripped my code back and followed the suggestion here:
When I run the code and debug it, I can see that the LinkedList number of elements is increasing with each add, but all the data is 'sitting' in the first index, with the later elements all empty.
public class editTextString {
private String str1;
private String str2;
private String str3;
public editTextString(String data1,String data2,String data3){
str1 = data1;
str2 = data2;
str3 = data3;
}
public static void main(String[] args) {
ArrayList<editTextString> list = new ArrayList<editTextString>();
editTextString data = new editTextString("edit1","edit2","edit3");
list.add(data);
list.add(data);
list.add(data);
}
Expected output: List to have 3 elements each with three substrings within. Actual output: List with 3 elements, first contains three substrings, next two are empty.
list.get(1).str1?)