1.

How to not allow serialization of attributes of a class in Java?

Answer»
  • In order to achieve this, the ATTRIBUTE can be declared along with the USAGE of transient keyword as shown below:
public class InterviewBitExample { private transient String someInfo; private String NAME; private INT id; // : // Getters SETTERS // :}
  • In the above example, all the fields except someInfo can be serialized.


Discussion

No Comment Found