I'm looking to improve my Java coding.
Can someone provide a link or an explanation on whether there's a code of practise to initialise ArrayLists and avoid the following problem:
-I have 6 ArrayList in one class, some are subsets of others. Because some are subsets of others I understand they share the same references through the "addAll()" and "add()" methods.
As a result, by attempting to change the elements in subsets I'm also altering the original sets because again - they share the same reference. My code is so messy that a few "get" calls results in 2 of my ArrayLists being reset.
I have researched this forum and google and I can't seem to find the relevant information I want. I only find simple examples of ArrayLists. I have noticed that there are a few ArrayList reference related questions on this forum so I think the answer to this question will benefit others in the future.