Does a Java Array have to be assigned a length in the beginning? or can it be dynamic and accept unlimited amounts of data until the user decides that is enough?
Everywhere I look the length is always defined... example
public static void main(String[] args)
{
int a[] = new int[10];
System.out.println("Please enter your number: "\n);
}
Instead of having 10, is it possible to say at a time in the future when the user decides by entering a certain number, like -1, the array is complete? Therefore, a user can continue to input information because they do not know how much information they will enter into the array. I did find in one place using (int ... number), is this a viable way of declaring no declared amount?
ArrayList?