Java arrays vs collections

How arrays and collections are similar.

  • Both can store multile occurrences of objects.
  • Some collection types (such as ArrayList) use arrays internally to store data.

How arrays and collections differ.

  • An array is a Java language feature. Collections are classes in the Java API.
  • Collection classes have methods that perform operations that arrays don't provide.
  • Arrays are fixed in size. Collections are varialbe in size.
  • Arrays can store primitive types. Collections can't.
  • Indexes are almost always required to process arrays. Collections are usually processed without using indexes.

Description

A collection is an object that can hold other objects. Collections are similar to arrays, but are ore fleible to use and are more efficient that arrrays for many applications.