I am new to java programming and I have to write an inventory program that can hold multiple items. I have my code from week 1 but I do not know how to write in the ability to hold multiple inventory items. Can anyone help with this?
rob.sigmon.1
0
Light Poster
Recommended Answers
Jump to PostYou could use an array, matrix (multidimensional array), Vector, List, ArrayList, Collection, Map...
In my opinion, then simplest would probably be to useList<InventoryItem> inventory = new ArrayList<>();
Jump to PostYes, we can, but we'd need to know what you have done already, or at least what you know how to do. We might need to see your code, or at least the part you are having problems with.
If you need to post part of tyour code, use the …
Jump to PostYou would presumably replace
Cars product = new Cars(2479, "BMW M6", 45, 65000);
with
Cars[] products = new Cars[10]; // or however large the lot is supposed to be
You would then have to initialize each of the elements with …
Jump to PostA standard
for()
loop is used to repeat something a fixed number of times, with one variable - the index - changing on each iteration. It is similar to anif()
orwhile()
, except that the conditional has three parts: the initializer, the condition, and the iterator. …
Jump to PostI'd have to see the code that's having the problem to be able to tell you the answer, I'm afraid. Without that, all I could do is guess. What symbol is it saying it can't find?
All 20 Replies
TylerD75
0
DaniWeb Newbie
Schol-R-LEA
1,446
Commie Mutant Traitor
Featured Poster
rob.sigmon.1
0
Light Poster
rob.sigmon.1
0
Light Poster
Schol-R-LEA
1,446
Commie Mutant Traitor
Featured Poster
rob.sigmon.1
0
Light Poster
Schol-R-LEA
1,446
Commie Mutant Traitor
Featured Poster
rob.sigmon.1
0
Light Poster
Schol-R-LEA
1,446
Commie Mutant Traitor
Featured Poster
rob.sigmon.1
0
Light Poster
Schol-R-LEA
1,446
Commie Mutant Traitor
Featured Poster
TylerD75
0
DaniWeb Newbie
rob.sigmon.1
0
Light Poster
JamesCherrill
4,733
Most Valuable Poster
Team Colleague
Featured Poster
rob.sigmon.1
0
Light Poster
rob.sigmon.1
0
Light Poster
rob.sigmon.1
0
Light Poster
Schol-R-LEA
1,446
Commie Mutant Traitor
Featured Poster
rob.sigmon.1
0
Light Poster
pookie47
0
Newbie Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.