File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes Persistant State Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Persistant State" Watch "Persistant State" New topic

Persistant State

Ransika deSilva
Ranch Hand

Joined: Feb 18, 2003
Posts: 524
Could you please explain what a Persistant State means.
Thank You .................

SCJP 1.4, SCMAD 1.0<br />SCWCD, SCBCD (in progress)
Dirk Schreckmann

Joined: Dec 10, 2001
Posts: 7023
The concept of persisting state is simply to somehow remember the state of something for later retrieval and use.
For example, the JavaServer Faces framework has as one of its features the ability to persist the state of a GUI beyond a single interaction with a user. In other words, if you're working with a GUI of some app that uses JavaServer Faces, this framework allows the developer to program the app such that it will remember changes you, the user, have created to the GUI.
Another contrived example might involve my bank account. When I use an ATM, it retrieves the state of my bank account (which is always some balance below what I want it to be) and allows me to change it in various ways. When I've finished with my account manipulations, the ATM and the banking system persist (remember) the new state of my account for later use.
If you're having trouble understanding how this concept applies to a particular situation, perhaps you could explain a bit about the context that you're trying to understanding these things in.

[How To Ask Good Questions] [JavaRanch FAQ Wiki] [JavaRanch Radio]
Igor Ko
Ranch Hand

Joined: Jun 24, 2002
Posts: 90
For example you save input strings in your program into ArrayList.
After this you close the program, and run again.
Oopps - you check the ArrayList and see that now it's empty.
You can create some special version of List that save somehow
data into disk (file, database), and have code to restore the data
at time of creation instance of the List.
Now after restart the program - you can see saved in previous
session, strings.
Now the object is persistent.
I agree. Here's the link:
subject: Persistant State
jQuery in Action, 3rd edition