• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Share objects in a standalone java application

 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi everybody,
I am fairly new to Java and want to know all the possible mecahnisms to share objects in a standalone java application.
Thanks
 
Ranch Hand
Posts: 3451
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


... all the possible mecahnisms to share objects in a standalone java application.


I doubt that they've all been tried. All objects are unique (one of the core principles of Object Orientation) and can be shared among any other object in a variety of ways. They can be passed as parameters in methods, they can be returned from methods, they can be referenced directly as fields, they can be members of collections, etc. The thing to remember in Java though is that objects can only be accessed by a reference. Objects can become orphaned when there are no longer any reference that refer to them. When that happens they become subject to garbage collection.
Michael Morris
[ March 20, 2003: Message edited by: Michael Morris ]
 
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
...and then there's all those funny persistence strategies.
Welcome to JavaRach, Janelle! What are you trying to accomplish?
 
Janelle Goldsmith
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for the welcome.
I heard about storing the objects in persistent storage like files etc.
When would that be used in a standalone java application ?
 
Ranch Hand
Posts: 2937
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


I heard about storing the objects in persistent storage like files etc.
When would that be used in a standalone java application ?


Whenever you need to store and retreive the state of the object. For example, your program monitors the stock market activity during the trading day. After the trading day, you can close your app. When you restart it the next day, your program will restore its state and resume execution.
Eugene.
reply
    Bookmark Topic Watch Topic
  • New Topic