Similarities and differences of arrays and lists?

Hi guys. I just began programming and I stumbled upon arrays and lists. I still don't fully understand them. Can anyone tell me the similarities and differences of the two? Thanks. :)


The main difference is how the data is stored in memory - for example, an array is stored sequentially i.e.

int myArray[5];

would be like...

myArray[0]..myArray[1]...etc

With lists (or linked lists as most call them) they contain a pointer to the next element and previous element, and with lists I could insert another element anywhere within the list - you cant with a arrays as they are static.

In a nutshell, a linked list can grow and shrink in size during runtime.
Topic archived. No new replies allowed.