Getting NotSerializableException on a serializable object

后端 未结 2 663
猫巷女王i
猫巷女王i 2021-01-20 04:00

Basically, I\'ve written a program that paints shapes onto the screen, and saves each of the shapes into an ArrayList. What I want to do is figure out how to save the ArrayL

2条回答
  •  佛祖请我去吃肉
    2021-01-20 04:49

    Based on the call you are making to repaint() in Shape, I'm guessing that it is in inner class. It therefore has a hidden variable referencing its enclosing instance. It will try to serialize that object along with itself. Is the outer class serializable? Or better yet, could Shape be made into an ordinary top-level class?

提交回复
热议问题