Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to create an open-ended array?

I was wondering if I could create an array without having to enter a value. I don't fully understand how they work, but I'm doing an inventory program and want my array to be set up in a way that the user can enter products and their related variables until they are done, then it needs to use a method to calculate the total cost for all the products. What would be the best way to do that?

like image 227
russ Avatar asked Dec 29 '22 00:12

russ


1 Answers

Use an ArrayList.

This will allow you to create a dynamic array.

http://download.oracle.com/javase/1.5.0/docs/api/java/util/ArrayList.html

Here is an example/overview:

http://www.anyexample.com/programming/java/java_arraylist_example.xml

like image 88
Brandon Frohbieter Avatar answered Dec 30 '22 13:12

Brandon Frohbieter