Your HashMap
itself is serializable but is the Bottle
class serializable? If not, it will not serialize and will throw errors at runtime.
Make the Bottle
class implement the java.io.Serializable
interface
I was getting this error because my class wasnt Serializable
. To make my class serializable I had to add : Serializable
at the end of class to make is Serializable. Just like this
class Shirt(val price: Double, val discountedPrice: Double) : Serializable
Make sure to import Serializable
like this
import java.io.Serializable
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With