当前位置:网站首页>guava:Collections. The collection created by unmodifiablexxx is not immutable
guava:Collections. The collection created by unmodifiablexxx is not immutable
2022-07-06 21:33:00 【amadeus_ liu2】
One 、 Example
package com.example.app;
import com.google.common.collect.ImmutableSet;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
public class ImmutableTest {
public static void main(String[] args) {
List<String> stringList=new LinkedList<>();
stringList.add("abc");
stringList.add("def");
List<String> stringList1 = Collections.unmodifiableList(stringList);
stringList.remove(0);
System.out.println(stringList1);
}
}
Run program output :
Cannot pass Collections.unmodifiableXXX Create a reference to modify the object , But because of the original stringList It can be modified , and stringList1 and stringList Point to the same object ,stringList Modification will inevitably make stringList1 change .
边栏推荐
- string的底层实现
- How to implement common frameworks
- OneNote in-depth evaluation: using resources, plug-ins, templates
- b站视频链接快速获取
- 袁小林:安全不只是标准,更是沃尔沃不变的信仰和追求
- VIM basic configuration and frequently used commands
- Deployment of external server area and dual machine hot standby of firewall Foundation
- @GetMapping、@PostMapping 和 @RequestMapping详细区别附实战代码(全)
- [redis design and implementation] part I: summary of redis data structure and objects
- 快讯:飞书玩家大会线上举行;微信支付推出“教培服务工具箱”
猜你喜欢
![[Li Kou brush questions] 32 Longest valid bracket](/img/51/1ce4f9e8517dba214ec82b6567c923.png)
[Li Kou brush questions] 32 Longest valid bracket

LLVM之父Chris Lattner:为什么我们要重建AI基础设施软件

Data Lake (VIII): Iceberg data storage format

2022菲尔兹奖揭晓!首位韩裔许埈珥上榜,四位80后得奖,乌克兰女数学家成史上唯二获奖女性

【滑动窗口】第九届蓝桥杯省赛B组:日志统计

缓存更新策略概览(Caching Strategies Overview)

Quick news: the flybook players' conference is held online; Wechat payment launched "education and training service toolbox"

50个常用的Numpy函数解释,参数和使用示例

966 minimum path sum

快讯:飞书玩家大会线上举行;微信支付推出“教培服务工具箱”
随机推荐
What's the best way to get TFS to output each project to its own directory?
In JS, string and array are converted to each other (II) -- the method of converting array into string
缓存更新策略概览(Caching Strategies Overview)
js 根据汉字首字母排序(省份排序) 或 根据英文首字母排序——za排序 & az排序
@GetMapping、@PostMapping 和 @RequestMapping详细区别附实战代码(全)
Sdl2 source analysis 7: performance (sdl_renderpresent())
Yyds dry inventory run kubeedge official example_ Counter demo counter
FZU 1686 龙之谜 重复覆盖
JS operation DOM element (I) -- six ways to obtain DOM nodes
Comparison between multithreaded CAS and synchronized
Nodejs tutorial expressjs article quick start
对话阿里巴巴副总裁贾扬清:追求大模型,并不是一件坏事
2022菲尔兹奖揭晓!首位韩裔许埈珥上榜,四位80后得奖,乌克兰女数学家成史上唯二获奖女性
C # use Oracle stored procedure to obtain result set instance
愛可可AI前沿推介(7.6)
R3live notes: image processing section
Nodejs tutorial let's create your first expressjs application with typescript
2022 fields Award Announced! The first Korean Xu Long'er was on the list, and four post-80s women won the prize. Ukrainian female mathematicians became the only two women to win the prize in history
嵌入式开发的7大原罪
PHP saves session data to MySQL database