| | |
Storing Objects
![]() |
•
•
Join Date: Oct 2007
Posts: 59
Reputation:
Solved Threads: 0
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
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
Use an ArrayList (this is dynamic whereas an array is fixed length).
Java Programmer and Sun Systems Administrator
----------------------------------------------
Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.
--Brian Kernighan
----------------------------------------------
Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.
--Brian Kernighan
![]() |
Similar Threads
- Storing Text file in Database through VB (Visual Basic 4 / 5 / 6)
- help:stl vector of user defined objects (C)
- How do I delete an instance of an Array? (C++)
- Passing arrays of objects to functions (C++)
- Calling Object Methods within a LinkedList (Java)
- Object-Oriented Programming (C++)
- C++ Data Types (C++)
Other Threads in the Java Forum
- Previous Thread: URLConnection problem
- Next Thread: exe creation and its usage without jdk/jre
| Thread Tools | Search this Thread |
account android applet application apps array automation awt bidirectional binary birt bluetooth businessintelligence busy_handler(null) card class classes client code collision columns component constructor database designadrawingapplicationusingjavajslider draw eclipse error eventlistener exception expand fractal free game givemetehcodez graphics gui guidancer homework html ide image inheritance integer integration intellij j2me java javafx javamicroeditionuseofmotionsensor javaprojects jlabel jme jni jpanel jtextfield jtree julia linux loop method midlethttpconnection migrate mobile mobiledevelopmentcreatejar monitoring myaggfun netbeans newbie nullpointerexception open-source oracle plazmic print problem program property ria scanner server set sharepoint smart sms smsspam sourcelabs splash sql sqlite subclass support swing testautomation textfield threads tree trolltech unlimited utility windows






