Reputation: 9170
I have a question about linked lists in java. I saw an interesting approach of getting arguments from the commandline into a java program, via String[] args. The very interesting part on this was that all Strings were added to a LinkedList which later is iterated in order to interpret all options.
So the question is, what happens if you excessivly use this LinkedList with a very very very large ammount of data? Are there any ways you could break it up to create a buffer overflow, or is it just working until there is no more memory allocatable?
greetings,
vlad
Upvotes: 2
Views: 279
Reputation: 31647
Check below links... Those will help you...
Maximum size of HashSet, Vector, LinkedList
http://docs.oracle.com/javase/tutorial/collections/implementations/index.html
Good Luck!!!
Upvotes: 1
Reputation: 2866
For buffer overflows in languages like Java, this thread might be interesting to you: Does Java have buffer overflows?
Upvotes: 1
Reputation: 5126
There shouldn't be any issues with a large argument list outside of memory usage or performance. Realistically speaking you probably won't get to enough arguments on the command line to cause any kind of memory or performance issues.
Note that you could probably store a reference to the args array instead of creating a new linked list from it (unless you have a specific reason to).
Upvotes: 1
Reputation: 2496
LinkedList
s will expand to accomodate new elements and won't overflow.
Note however that they will have a larger overhead than a simple array, and thus you may run out of memory faster using a LinkedList than an array.
Upvotes: 2