当前位置:网站首页>List related knowledge points to be sorted out

List related knowledge points to be sorted out

2022-07-04 23:07:00 Zhang Ziwa

Arrays.asList() and new ArrayList() difference :

Arrays.asList() and new ArrayList() Back to List All inherited AbstractList
but new ArrayList<> Some methods have been rewritten 、 Support add(),remove() operation
and Arrays.asList(st1) Only inheritance , No rewriting 、 I won't support it add(),remove() operation , Only traversal read operations are supported ;

List.of() and Arrays.asList() difference

https://blog.csdn.net/qq_42520962/article/details/109380430
1、Arrays.asList() Can contain /contains null, and List.of() Cannot contain /contains null (NullPointerException)
2、List.of Generated List Do not modify ,Arrays.asList Generated List Can modify ; Such as ls1.set(0,5);
3、 About array modification List Influence . Array modification pair Arrays.asList Generated List Have an impact on , Yes List.of Generated List No influence :

原网站

版权声明
本文为[Zhang Ziwa]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/185/202207042236530902.html