Hello Ranchers, I can't clearly understand the reply posted for one of the "There are no DUMB QUESTIONS" in page no. 72. que.1: I'm sitting here with a HashMap full of serializable Customer objects with string keys. Do I have to worry about whether the HashMap itself is Serializable ? All of the implementations of Collection interface are serializable but why would the return type of values() should be relied upon for serializability. Any input detailing a little more on the reply is appreciated ! ~ Shalini
A good question from Torean!!!i spent quite a bit of time & came up with a question on values() from hashmap returns a collection, what we can do is to fill the returned collection into an arraylist to make the objects surely serializable as the book says, but my question is ? i went through the AbstractList class and it does not implement the serializable interface ,may be that is why the returned collection be fed into a known collection implementing class(to make sure that the classs is serializable), but the book says in 72-page that all collection implementations are serializable ? please help me & Torean thanks
Failure is not when you fall down; its only when you fail to get up again.
As per my thought,values() method of HashMap returns Collection interface which doesn't extend serializable interface.So it is not serializable and so is not shippable.There is a way to convert Collection we get from values() method to serializable object.We can use ArrayList since this class implements Serializable.Use ArrayList constructor public ArrayList(Collection c) .
"Continuous effort - not strength or intelligence - is the key to unlocking our potential."