This week's book giveaway is in the Cloud/Virtualization forum.
We're giving away four copies of Learning OpenStack Networking: Build a solid foundation in virtual networking technologies for OpenStack-based clouds and have James Denton on-line!
See this thread for details.
Win a copy of Learning OpenStack Networking: Build a solid foundation in virtual networking technologies for OpenStack-based clouds this week in the Cloud/Virtualization forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

what is state and persistance?  RSS feed

 
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • 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
Java Mac Safari
  • Mark post as helpful
  • send pies
  • 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 ]
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!