How does marking a field as transient make it possible to serialise an object

前端 未结 3 743
暗喜
暗喜 2020-12-05 19:56
public class Foo implements java.io.Serializable {
   private int v1;
   private static double v2;
   private Loan v3 = new Loan();
}

Options:

3条回答
  •  伪装坚强ぢ
    2020-12-05 20:44

    Then how is transient in this case, helping us to serialize foo?

    Because it allows you to serialize the rest of Foo, the other members that are serializable.

提交回复
热议问题