0
点赞
收藏
分享

微信扫一扫

List<String> 和 ArrayList<String>的区别(简单易懂)

君心浅语 2022-06-28 阅读 165

声明ArrayList list=new ArrayList()与List list=new ArrayList()都是可以的,但是前者不推荐,因为后者声明的对象更灵活。
比如:

List<String> strings = new ArrayList<>();
strings = new LinkedList<String>();

有时候很多需求只能用一个list,内存有限,或者线程同步,不能有更多的集合对象,使得List总的接口来管理对象。


举报

相关推荐

0 条评论