-
Notifications
You must be signed in to change notification settings - Fork 784
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
2019-07-04:Kotlin中List与MutableList的区别? #90
Comments
Ground floor |
MutableList:可读写,实际上就是个ArrayList |
List:有序接口,只能读取,不能更改元素; |
Kotlin中List、Set、Map与Java中的List、Set、Map有一些不同,kotlin中为只读,只能访问集合中的内容,不能进行修改操作。 |
kotlion中的List是只可读不可写。如果需要读写操作可以用MutableList表示可变的list |
只读集合不一定是不可变的,如果你拥有的变量是只读接口类型,它有可能是同一个集合众多引用中的一个,而这些引用中可能存在可写读的接口类型。 |
List 返回的是EmptyList,MutableList 返回的是一个 ArrayList,查看EmptyList的源码就知道了,根本就没有提供 add 方法。
} 以前看过一篇文章,主要介绍的就是关于 MutableList 和 List 源码分析的,找不到了。 |
No description provided.
The text was updated successfully, but these errors were encountered: