0

Why can't a class implementing Externalizable use the auto generated no-arg construtor provided by the JVM? Why does it need a no-arg constructor?

aastha
  • 1
  • 1
  • Possible duplicate of [Why does implementing Externalizable need a default public constructor?](http://stackoverflow.com/questions/8627996/why-does-implementing-externalizable-need-a-default-public-constructor) – Anya Shenanigans Jan 23 '17 at 09:19
  • No,my question is slightly different. I'm asking why can't it use the auto generated no-arg construtor provided by the JVM? – aastha Jan 24 '17 at 04:37
  • It's to cover the non-static inner class case, where default no-arg constructors are not created. – Anya Shenanigans Jan 24 '17 at 08:33
  • I'll just clarify: It will use the auto-genrated no-arg constructor if there is no other constructor present, but you are required to *have* a no-arg constructor for it to work. Once you write even a single-arg constructor, then you won't have the default no-arg constructor. – Anya Shenanigans Jan 24 '17 at 15:55

0 Answers0