Java.io.ObjectStreamField.isUnshared() Method
Advertisements
Description
The java.io.ObjectStreamField.isUnshared() method returns boolean value indicating whether or not the serializable field represented by this ObjectStreamField instance is unshared.
Declaration
Following is the declaration for java.io.ObjectStreamField.isUnshared() method
public boolean isUnshared()
Parameters
NA
Return Value
This method does not return a value.
Exception
NA
Example
The following example shows the usage of java.io.ObjectStreamField.isUnshared() method.
package com.tutorialspoint;
import java.io.*;
import java.util.Calendar;
public class ObjectStreamFieldDemo {
public static void main(String[] args) {
// create a new object stream class for Integers
ObjectStreamClass osc = ObjectStreamClass.lookup(Integer.class);
// get the field value from Integer class
ObjectStreamField field = osc.getField("value");
// check if field is unshared
System.out.println("" + field.isUnshared());
// create a new object stream class for calendar
ObjectStreamClass osc2 = ObjectStreamClass.lookup(Calendar.class);
// get the field value from Integer class
ObjectStreamField field2 = osc2.getField("isSet");
// check if field is unshared
System.out.println("" + field2.isUnshared());
}
}
Let us compile and run the above program, this will produce the following result:
false false