Hi
During java serialization we can persist the object state i.e. we can change object state into byte stream and save into file for future use
we can achieve it by implementing class with Serialization interface
If you want to prevent persist object property then use Transient and Static keyword before property declartion
Code:
in Above code we you serialize object property num and num2 will be not serialize
During java serialization we can persist the object state i.e. we can change object state into byte stream and save into file for future use
we can achieve it by implementing class with Serialization interface
If you want to prevent persist object property then use Transient and Static keyword before property declartion
Code:
public class testClass implements serialization
{
public transient int num=5;
public static int num2=8;
}
in Above code we you serialize object property num and num2 will be not serialize
No comments:
Post a Comment