I am relatively new to Java and over the years I had to solve all sorts of programming problems where the number of data that needs to be collected is really unknown to the programmer.
Is it a good convention to use Lists to collect strings or integer values when the programmer has no way of knowing the amount of variables that needs to be collected? Or is there a better way to handle this using dynamic arrays in Java?
If in doubt, using a List is likely to be a better choice even if you know the length.
Using an array can be better for performance, but you need to be an expert to know when this is a good idea, and when it just makes your solution more complicated.
BTW: There is no such thing as
dynamic arraysin Java.