문제

Every example I have seen regarding object serialization, includes an all field constructor and a getter and setter method for every field. Is this nessecary? What do you have to do to make a java object serializable, other tagging it with the serializable interface and assuring all non-transient field are them selves serializable.

도움이 되었습니까?

해결책

There is nothing required to make an Object serializable, apart from the basic steps you've mentioned. There are no requirements for the existence of getters/setters or constructors of a certain form (though there may be other legitimate reasons to want those).

다른 팁

The constructor/getters/setters are not mandatory. Non-transient collections although serializable containing references to non-serializable objects will cause failures.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top