You should only suppress the warning if you know why it is there. In this case, since it sounds like you understand the issue and are taking steps to deal with it, then suppressing it is probably ok. If, however, you are hellbent on making the warning go away, the only method I have found to do that in this case is to do something like this:
public class ListOfRectangles extends ArrayList<Rectangle> {}
And then use ListOfRectangles
as your data type for serializing to and from the file.
The reason the compiler is ok with char [] []
and not ArrayList<Rectangle>
is because of a concept with Java generics known as erasure. It means that for generic types (like ArrayList
) the parameterized type (Rectangle
in this case) is not actually present in the bytecode. It is only there during compile-time so that the compiler can double-check your work. This is not the case with arrays.
There is a more in-depth look at generics here