The limitations of arrays
The Limitations of Arrays
Arrays are extremely useful and are widely used in Java programs. They have limitations however. You need to know how many elements they will contain when you create them and every element must be of the same type. Thus you cannot create an array that stores an number for Salary and two Strings for first and last name. When a program is running you may not know how many elements are going to be needed. You can use a variable to control how many elements are created, but if you subsequently find your array needs to be bigger you are stuck with the original size. If you want to store multiple element of different types in one named storage unit, you can use the classes based on the Java Collections interface.
Last modified: Thursday, 24 July 2014, 2:54 PM