首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往

【Kotlin】集合操作 ② ( MutableList 可变列表集合 | 修改 MutableList 集合的 mutator 函数 )

文章目录 一、MutableList 可变列表集合 二、修改 MutableList 集合的 mutator 函数 1、添加元素运算符 += 和 删除元素运算符 -= 2、通过 Lambda 表达式筛选要删除的元素...一、MutableList 可变列表集合 ---- 使用 listOf 函数 创建的 List 集合 是 只读列表集合 ; 使用 mutableListOf 函数 创建的 MutableList 集合...// 添加元素 mutableList.add("Jack") // 删除元素 mutableList.remove("Tom") println(mutableList...val mutable: MutableList = list.toMutableList() } 执行结果 : [Jerry, Jack] 二、修改 MutableList..." 其效果等同于 mutableList.add("Jack") 从 MutableList 集合 中删除一些元素 , 可使用 -= 运算符 : mutableList -= "Tom" 其效果等同于

67430
您找到你想要的搜索结果了吗?
是的
没有找到

【Kotlin】集合操作总结 ( List 集合 | MutableList 集合 | List 集合遍历 | Set 集合 | MutableSet 集合 | Map 集合 | 可变 Map集合 )

("Jack") // 删除元素 mutableList.remove("Tom") println(mutableList) // 将 可变列表集合 转为 只读列表集合...val list: List = mutableList.toList() // 将 只读列表集合 转为 可变列表集合 val mutable: MutableList... = list.toMutableList() } 执行结果 : [Jerry, Jack] 五、修改 MutableList 集合的 mutator 函数 ---- 修改 MutableList...删除元素运算符 -= ; 向 MutableList 集合 中添加一些元素 , 可使用 += 运算符 : mutableList += "Jack" 其效果等同于 mutableList.add("Jack...") 从 MutableList 集合 中删除一些元素 , 可使用 -= 运算符 : mutableList -= "Tom" 其效果等同于 mutableList.remove("Tom") 2、通过

4.8K20
领券