Python,c,jav

Updated on May 18, 2017 in [A] Tutorials
Share on Facebook0Tweet about this on TwitterShare on Google+0Share on Reddit0
2 on May 15, 2017

what is the difference between array and list?

  • Liked by
Reply
0 on May 15, 2017

An array can’t have a key that’s a string (something between “”) while a List can.

Edit: Nope my statement is not true, have you tried actually searching for the difference?
http://stackoverflow.com/a/32020072/6341708 I thought this summed it up pretty nicely

  • Liked by
Reply
Cancel
0 on May 18, 2017

Just as the post from Job’s link states, Arrays are a set size. When you initialize an array, you must give it a size ( even if it is just it’s contents ( int[] numbers = { 1, 12, 5, 6 } has a a size of 4) ), while a list can be initialized empty or with a size. To my knowledge, it is “better” to use an array when you can.

So decide, is your data structure going to need to change in size? Are you going to be adding anything to it? If so, use a list.

If you are doing something more like “The number of months in a year”, well, that will always be 12. Use an array.

  • Liked by
Reply
Cancel