In Java, you can use either a Vector or a one-dimensional array to store an ordered collection of objects. The difference between the two types of storage is that the array allocates storage for a fixed number of elements where as the Vector can grow dynamically. Another difference is that an array can be used to store primitives (int, boolean, etc.) where as a Vector can only store pure objects. You should also keep in mind that arrays are type-safe. An array can only store objects of a particular class and only objects of that class can be retrieved from it. Assigning that object to a variable of its type requires no explicit casting. For example:
SomeObject[] soArray = new SomeObject[10];// Fill array with some objectfor (int i = 0; i < 10; i++) soArray[i] = new SomeObject(i);// Get objects from the arrayfor (int i = 0; i < 10; i++) SomeObject so = soArray[i];
The variable soArray only holds variables of the type