1、addAll() 与 of方法的区别是什么?
addAll是集合实现类的方法;
of是接口的方法,不适用于接口的实现类;
2、使用of方法容易出现的异常有哪些?分别对应of的什么限制使用条件?
unsupported operation exception 不支持操作异常 —— of 后不能集合不能再添加元素,再add,put报错;
illegal argument exception 非法参数异常 —— of 添加的元素不能重复,重复则报错;
1、addAll() 与 of方法的区别是什么?
addAll是集合实现类的方法;
of是接口的方法,不适用于接口的实现类;
2、使用of方法容易出现的异常有哪些?分别对应of的什么限制使用条件?
unsupported operation exception 不支持操作异常 —— of 后不能集合不能再添加元素,再add,put报错;
illegal argument exception 非法参数异常 —— of 添加的元素不能重复,重复则报错;