English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
An array is a container that can hold a fixed number of items, which should be of the same type. Most data structures use arrays to implement their algorithms. The following are important terms to understand the concept of arrays.
Element-Each item stored in an array is called an element.
Index: Each element in an array has a numeric index, which is used to identify the element.
The size of the array will be determined at the time of creation.
Delete or Insert-You cannot insert a new element in the middle of an array. Similarly, you cannot delete an element from the middle of an array. You can only insert from the end/Delete.
Increase Size-You cannot increase the size of an array in Java. If you want to add a new element, you need to create a new array with an expanded size and assign it to the array reference. This leaves the original object for garbage collection, thereby wasting memory.
Store Object-You can store objects in an array, but you cannot store objects of different types.
Handle Element-In addition to some operations provided by the Array class, you cannot handle the content of the array.
Modify Element-To delete or change an element in an array, you need to traverse the entire array, which increases the time complexity.
To overcome these shortcomings, you can use a set instead of an array.