Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 4 of 4

Thread: what is the use of transient class and serializable interface?

  1. #1
    Junior Member
    Join Date
    Oct 2009
    Posts
    19
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default what is the use of transient class and serializable interface?

    hi everybady,
    i want to know, what is the use of transient, valatile keywords in java
    and what is the use of serializable interface?
    where and how we preserve the state of the object?


  2. #2
    Super Moderator Json's Avatar
    Join Date
    Jul 2009
    Location
    Warrington, United Kingdom
    Posts
    1,274
    My Mood
    Happy
    Thanks
    70
    Thanked 156 Times in 152 Posts

    Default Re: what is the use of transient class and serializable interface?

    Transient means something is invisible to serialization.

    Volatile information can be found at Java theory and practice: Managing volatility

    Serializable is a marker interface to mark a class as serializable.

    You can preserve the state of an object by using some sort of persistence like a database or file.

    Here is an interface for this thread.

    public interface Googleable {
        public List<GoogleResults> search(final String query);
    }

    // Json

  3. The Following User Says Thank You to Json For This Useful Post:

    chinni (October 20th, 2009)

  4. #3
    Junior Member
    Join Date
    Oct 2009
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: what is the use of transient class and serializable interface?

    Transient is keyword, it is member variable of the class. This variable not persist when an object are stored or Serialized.
    Serialization is an interface by which you can save the state of an object by converting it to a byte stream. Objects are passing through the network in byte format. This is Usage of Serialization interface.

  5. #4
    Junior Member
    Join Date
    Oct 2009
    Location
    Pottstown, PA
    Posts
    3
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Re: what is the use of transient class and serializable interface?

    Serialization is a way to store or transmit Java objects. Since objects refer to other objects, serialization recursively saves the "entire" object. Serialized objects can be saved to a disk file or sent over a communications link. "Reading" the result is then called deserialization, where the original object is reconstructed. If the object is stored to a disk file, the file is readable via Java, but nothing else.

    Transient is something you use to tag a field that you do not want serialized. The simplest case would be a field that you plan to recompute each time, such as a sequence number, or a time field. If this value wouldn't be the same or make sense the next time you deserialize a class you could should use transient. Transient can also be used to tag a reference field so that serialization ignores this object. You might want to do this to reduce the amount of serialized data.

    Volatile has nothing to do with serialization, but does have something to do with synchronization and threading.

    Tom

Similar Threads

  1. SOMEONE PLEASE HELP ME ADD THE ACTIONLISTENER INTERFACE...
    By beginning2Understand in forum AWT / Java Swing
    Replies: 5
    Last Post: June 30th, 2009, 12:42 AM
  2. Getting an error while altering a source code
    By marksquall in forum Collections and Generics
    Replies: 3
    Last Post: June 8th, 2009, 02:49 AM
  3. Problem while implementing a basic user interface menu
    By Rastabot in forum File I/O & Other I/O Streams
    Replies: 3
    Last Post: April 3rd, 2009, 04:38 PM