what's difference between array and list code example
Example 1: Difference between Array vs ArrayList
Arrays are fixed size
ArrayList's size auotomatically adjusted
Arrays can hold primitives and object
ArrayList can hold only objects
Arrays can be multi dimensional
ArrayList cannot be multi-dimentional
Array is a build in data structure
ArrayList is implementing class of List interface in Collection framework
Example 2: java difference between array and list
In general (and in Java) an array is a data structure generally
consisting of sequential memory storing a collection of objects.
List is an interface in Java, which means that it may have multiple
implementations. One of these implementations is ArrayList, which
is a class that implements the behavior of the List interface using
arrays as the data structure.
Example 3: diff between array and list
The main difference between these two data types is the operation you can perform on them. Arrays are specially optimised for arithmetic computations so if you’re going to perform similar operations you should consider using an array instead of a list.
Also lists are containers for elements having differing data types but arrays are used as containers for elements of the same data type.