I have an Iterable<MyRecord> records
. I iterate over the records like below and add it to a LinkedList as shown below.
for (MyRecord record: records){
sortedList.addLast(record);
}
My iterable has 3 records, all with different values. But in the end although sortedList
contains 3 records, ALL THREE ARE THE SAME!!!. How come?
When I printed out the memory location, it's the same for all 3. What am I doing wrong?