Why does ObjectOutputStream.writeObject(Object o) not take a Serializable? Why is it taking an Object?
Why does ObjectOutputStream.writeObject(Object o) not take a Serializable ? Why is it taking an
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
This is because
writeObjectinObjectOutputStreamoverrides the method in theObjectOutputinterface which does not require that the object beSerializable.The
ObjectOutputinterface specifies methods that allow objects to be written to a stream or underlying storage, but this may be achieved by a process other than serialization. TheObjectOutputStreamimplements this functionality, but requires serializable objects. However, it cannot modify the signature of the interface that it implements.