Kotlin 中 MutableList 和 List 的区别 [英] Difference between MutableList and List in Kotlin

查看:48
本文介绍了Kotlin 中 MutableList 和 List 的区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  1. Kotlin 中的 MutableListList 有什么区别?
  2. 以及每种类型的用途是什么?
  1. What is the difference between MutableList and List in Kotlin?
  2. and what is the use of each type?

推荐答案

来自文档:

列表:元素的通用有序集合.此接口中的方法仅支持对列表的只读访问;通过 MutableList 接口支持读/写访问.

List: A generic ordered collection of elements. Methods in this interface support only read-only access to the list; read/write access is supported through the MutableList interface.

MutableList:支持添加和删除元素的通用有序元素集合.

MutableList: A generic ordered collection of elements that supports adding and removing elements.

您可以修改 MutableList:更改、删除、添加...它的元素.在列表中,您只能阅读它们.

You can modify a MutableList: change, remove, add... its elements. In a List you can only read them.

这篇关于Kotlin 中 MutableList 和 List 的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆