954,206 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Storing Objects

Hi, I have a project on which I am working.
I have two classes. A box Class which is of an undefined capacity and is only defined when an instance of the box class is made and I have an item class of which instances of it must be stored in the box. How might I represent this. Particularly When I create an Item how do I store it in the box as I may have to make more than one item per box created. I should also be able to subtract item from the box.

My attempt had me make an item array in the box class does that seem wrong. It does to me.

Any help would be appreciated.


Many thanks

Grub
Junior Poster in Training
60 posts since Oct 2007
Reputation Points: 14
Solved Threads: 0
 

Use an ArrayList (this is dynamic whereas an array is fixed length).

masijade
Industrious Poster
Moderator
4,253 posts since Feb 2006
Reputation Points: 1,471
Solved Threads: 494
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You