当前位置:网站首页>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 .
边栏推荐
- WEB功能测试说明
- None of the strongest kings in the monitoring industry!
- 抖音將推獨立種草App“可頌”,字節忘不掉小紅書?
- The biggest pain point of traffic management - the resource utilization rate cannot go up
- Is this the feeling of being spoiled by bytes?
- 互联网快讯:吉利正式收购魅族;胰岛素集采在31省全面落地
- The difference between break and continue in the for loop -- break completely end the loop & continue terminate this loop
- SDL2来源分析7:演出(SDL_RenderPresent())
- Deployment of external server area and dual machine hot standby of firewall Foundation
- Vim 基本配置和经常使用的命令
猜你喜欢
The biggest pain point of traffic management - the resource utilization rate cannot go up
HMS Core 机器学习服务打造同传翻译新“声”态,AI让国际交流更顺畅
HMS core machine learning service creates a new "sound" state of simultaneous interpreting translation, and AI makes international exchanges smoother
Why do job hopping take more than promotion?
[Li Kou brushing questions] one dimensional dynamic planning record (53 change exchanges, 300 longest increasing subsequence, 53 largest subarray and)
对话阿里巴巴副总裁贾扬清:追求大模型,并不是一件坏事
968 edit distance
Opencv learning example code 3.2.3 image binarization
3D人脸重建:从基础知识到识别/重建方法!
Swagger UI tutorial API document artifact
随机推荐
Aiko ai Frontier promotion (7.6)
js通过数组内容来获取数组下标
In JS, string and array are converted to each other (I) -- the method of converting string into array
KDD 2022 | 通过知识增强的提示学习实现统一的对话式推荐
El table table - get the row and column you click & the sort of El table and sort change, El table column and sort method & clear sort clearsort
Caching strategies overview
抖音將推獨立種草App“可頌”,字節忘不掉小紅書?
3D face reconstruction: from basic knowledge to recognition / reconstruction methods!
爱可可AI前沿推介(7.6)
14 years Bachelor degree, transferred to software testing, salary 13.5k
分糖果
Nodejs教程之Expressjs一篇文章快速入门
JS学习笔记-OO创建怀疑的对象
启动嵌入式间:资源有限的系统启动
3D face reconstruction: from basic knowledge to recognition / reconstruction methods!
ACdreamoj1110(多重背包)
袁小林:安全不只是标准,更是沃尔沃不变的信仰和追求
In JS, string and array are converted to each other (II) -- the method of converting array into string
Reflection operation exercise
Forward maximum matching method