I need to create several new objects from an ArrayList. Suppose my list is:
ArrayList<InvVoucher> list = .....;
int index = 0;
InvVoucher vch1 = list.get(index);
InvVoucher vch2 = list.get(index);
InvVoucher vch3 = list.get(index);
Here vch1
, vch2
and vch3
are holding the same object reference. How can I make all of them independent? How can I get three different copy of InvVoucher
?