• 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

How do I turn this object into an array....

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
is there a way without giving me the code, just giving me an explanation of how to put this data into an array that I can then serialize the array instead of just the member data. Is this clear?

Thanks,
Joe


[ March 09, 2006: Message edited by: Joe Wilkes ]
 
Ranch Hand
Posts: 194
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Use Reflection to make an array of the variable states and then serialize only that.
When you retrieve populate only that.
 
Joe Wilkes
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am not sure what that even means... Can you explain a little more. This is for my advanced java class and we are just getting into I/O.
 
Marshal
Posts: 28177
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That looks like working code. Why do you need to put something (I couldn't understand what) into an array? Does your assignment say to put something into an array, or is that your idea of a workaround for some problem you are having?
 
Joe Wilkes
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This is what the program is supposed to do. He wants there to be user input so I though this would be the easy way, maybe I am wrong. Would an array of strings work better to store data to?


Create a program that stores an array of objects (your choice) and then uses serialization to store that array of objects to a file. The objects in the array must contain at least one reference to another object. You will have to do a "deep copy" which means that all objects referenced must be "serializable"

 
Sam Codean
Ranch Hand
Posts: 194
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Oh i think the question is quite straightforward.
Make a Array of the Family Members class and populate each element of that array with some entries.
Now that you have the Array of Family members (each refering to another set of objects, name, address, phone etc.) you have to only serialize this array (Array is also an Object).
Write this serialized object to a file.
If you need further help feel free to contact me.
Hope that helps!!
 
Sam Codean
Ranch Hand
Posts: 194
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Joe,
I have modified your code a little. I could not test the code as i do not have a jdk1.5
Please see the comments on the code. Modify the Method that reads the FAmily Members and the code should work fine.
Hope that helps. Do reply in case you find issues or anyways

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

is there a way without giving me the code, just giving me an explanation of how to put this data into an array that I can then serialize the array instead of just the member data.

Doing someones homework for them doesn't really help them at all.
[ March 11, 2006: Message edited by: Garrett Rowe ]
 
Joe Wilkes
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thats ok, I figured it just before I read the post. Thanks for all the info guys, you really got me back on the right track....
 
Sam Codean
Ranch Hand
Posts: 194
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Oh Yes! I am sorry, next time i will not do that
 
Watchya got in that poodle gun? Anything for me? Or this tiny ad?
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic