【Java踩坑笔记】14_Collections.singletonList的坑:不能add也不能set
摘要:Collections.singletonList() 返回的 List 是"只读"的,调用 add() 或 set() 会抛 UnsupportedOperationException。不止如此,它还有一些你不知道的性能特点。一、问题现象
public class SingletonListTest {public static voi…
2026/6/30 23:24:48