Array and set, array set
Arrays and List sets are used to store data. Today we will talk about the differences between arrays and sets. Array: Data Type [] variable name = new data type [] {}; List set: List <data type> variable name = new list <data type> (); from their writing format, we can see that the length of the array needs to be specified. The length of the array is fixed and cannot be changed, but the List set is not required. The set can be changed to add or delete elements.
Example:
Create an array: int () nums = new int [3]; // specify the length
Int [] nums = {3, 1, 3}; // Variable Length
Create a List set:
List <int> nums = new list <int> (); // The length is not specified.
List <int> nums = new List <int> (2, 1, 6); // Variable Length
In addition, the array occupies less memory, and the traversal speed is fast. The reverse of the set. All functions that the array can implement can be implemented by the set, but the functions that the set can implement are hard to implement by the array.