Is it possible to serialize anonymous class without outer class?

前端 未结 6 980
广开言路
广开言路 2021-02-06 03:45

I made a small research on web and reviewed related topics on this site, but the answers were contradictory: some people said it is not possible, others said it is possible, but

6条回答
  •  攒了一身酷
    2021-02-06 04:15

    The answer is no. You cannot do that since Inner class will need outer class to be serialized. Also you would run into troubles when you'd try to call the instance method of the outer class within the inner class. Why don't you just have another top level class which you could send?

提交回复
热议问题