Collection与Collections;Array与Arrays

1:Collection是就和接口,set与list都是由其派生的接口。

      Collections是关于集合的工具类,封装了关于集合操作的静态方法,可以直接调用,比如Collections.sort();

2:Array是关于数组的接口,位于java.sql包,派生了serialArray接口。

      Arrays是关于数组的工具类,封装了各种操作数组的静态方法,可以直接调用,比如Arrays.sort();

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
C# provides two main data structures for storing collections of elements: List and Array. Both List and Array are used to store and manipulate a collection of items, but they have some differences in terms of flexibility and functionality. An Array is a fixed-size collection of elements of the same type. Once an array is created, its size cannot be changed. You need to specify the size of the array when declaring it. Array elements can be accessed using an index, starting from 0. Here's an example of creating and accessing elements in an array: ```csharp int[] numbers = new int[5]; // Creating an array of size 5 numbers[0] = 1; // Accessing and setting the value at index 0 int firstNumber = numbers[0]; // Accessing the value at index 0 ``` On the other hand, List is a dynamic collection that can grow or shrink in size. It allows adding, removing, and modifying elements easily. List provides several methods and properties to manipulate the collection efficiently. Here's an example of creating and manipulating elements in a List: ```csharp List<int> numbers = new List<int>(); // Creating an empty list numbers.Add(1); // Adding an element to the list int firstNumber = numbers[0]; // Accessing the value at index 0 numbers.Remove(1); // Removing an element from the list ``` In summary, Arrays have a fixed size, while Lists can dynamically grow or shrink. Arrays are generally more efficient in terms of memory, but Lists provide more flexibility and functionality for manipulating collections.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值