I have a spec that requires me to pass an array of lists. The array is always length 2. I am using the following to accomplish this:
List<MyClass> [] data = new ArrayList[2];
data[0] = new ArrayList<MyClass>();
data[1] = new ArrayList<MyClass>();
compiles but gives warning:
uses unchecked or unsafe operations.
I understand that Arrays of generics are not allowed in Java however I cannot change the spec and the above code seems to work nicely. As long as I am conscious that I never reassign the elements of the array to be something other than type ArrayList<MyClass>
are there any reasons I should not just suppress this warning and be on my way?
>`
– Hovercraft Full Of Eels Jan 09 '17 at 23:34