list vs array code example

Example 1: 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.

Example 2: list vs array python

#a list in Python stores multiple values
fruits = ['apples','bananas','oranges','cherries']

Tags:

Java Example