// Java can guarantee that the Object read back // is indeed an ArrayList of some sort of Objects, just not what type of Objects. // The array internal to the ArrayList is Object[], not Thing[], so that is no help // in ensuring the Object read back is an ArrayList. // We verify the objects in the ArrayList individually. // This is safer but considerably slower than suppressing the error message. // Does not generate a cast warning. final ArrayList temp = (ArrayList)ois.readObject(); final ArrayListthings = new ArrayList( temp.size() ); for ( Object item : temp ) { things.add( (Thing)item ); }