• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

what is state and persistance?

 
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi

I am confusing about state and persistance. Actually what is difference between them or is both are same?

please give details in example.


Regards
 
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Moving this to the Java in General (beginner) forum...
 
Ranch Hand
Posts: 214
IntelliJ IDE Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
State refers to the values of the properties of an object.

Persistence refers to the permanent storage of data (like storing in a database table), such as the state of an object. You persist the state of an object so that you can later restore (or re-create) that object just as it was before it was removed from memory (it was garbage collected, the program ended, etc.)
 
Sheriff
Posts: 11343
Mac Safari Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
State refers to the collective values of an object's variables.

Persistence refers to an object being saved outside of the Java program, so that it doesn't vanish when the program is finished. This is achieved by serializing an object, and the state of the serialized object is its "persistent state."

(Note that variables modified with the keyword "transient" are not stored to an object's persistent state.)

See the API for the Serializable interface (in java.io)...

http://java.sun.com/j2se/1.4.2/docs/api/java/io/Serializable.html

Also see "Object Serialization" in the Java Tutorial...

http://java.sun.com/docs/books/tutorial/essential/io/serialization.html

See especially the topic on "Providing Object Serialization for Your Classes," which discusses how to customize serialization (and thus an object's persistent state)...

http://java.sun.com/docs/books/tutorial/essential/io/providing.html
[ September 23, 2004: Message edited by: marc weber ]
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic