| | |
Storing Objects
![]() |
•
•
Join Date: Oct 2007
Posts: 60
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 |
911 actionlistener addressbook android api append applet application array arrays automation binary blackberry block bluetooth character chat class client code component consumer csv database desktop developmenthelp eclipse error fractal ftp game givemetehcodez graphics gui html ide image integer j2me j2seprojects japplet java javaarraylist javac javaee javaprojects jni jpanel julia lego linked linux list loops mac map method methods mobile netbeans newbie number objects online oriented panel printf problem program programming project projects properties recursion replaydirector reporting researchinmotion rotatetext rsa scanner se server set singleton sms sort sql string swing test textfields threads time title tree tutorial-sample ubuntu update windows working






