摘要:
一、ArrayList集合的具体特点: 底层的数据结构是数组,查询快,增删慢,线程不安全,效率高。 /* Collection[接口]: List[接口]: 元素有序,可以发生重复,有索引的概念 ArrayList[具体的子类]: 底层数据结构是数组,查询快,增删慢,线程不安全,效率高。 Set[接 阅读全文
posted @ 2024-10-15 22:22
你的镁偷走了我的锌
阅读(23)
评论(0)
推荐(0)
摘要:
需求:遍历集合,当遇到mango的时候,向集合中添加一个元素"java" public class ListDemo2 { public static void main(String[] args) { List list1 = new ArrayList(); list1.add("hello" 阅读全文
posted @ 2024-10-15 19:39
你的镁偷走了我的锌
阅读(12)
评论(0)
推荐(0)
摘要:
一、List是一个接口,其集合的特点是:元素可以发生重复,有序(指的是存入和输出的顺序一致) 二、List集合中特有的成员方法: 1.void add(int index,E element)向List集合中的指定位置添加元素 2.E remove(int index)在集合指定位置删除元素 3.E 阅读全文
posted @ 2024-10-15 19:27
你的镁偷走了我的锌
阅读(24)
评论(0)
推荐(0)
摘要:
一、第一种方法,将集合转换成数组,进行循环遍历 public class CollectionDemo3 { public static void main(String[] args) { Collection c1=new ArrayList(); c1.add("java"); c1.add( 阅读全文
posted @ 2024-10-15 19:04
你的镁偷走了我的锌
阅读(62)
评论(0)
推荐(0)
摘要:
一、Collection集合的介绍: 1.Collection是一个接口,List,Set是继承Collection接口的子接口 2.当我们使用Collection的方法的时候,由于是一个接口不能直接new对象,可以通过其具体实现的子类来进行调用 二、Collection 的基本方法(6) 1.bo 阅读全文
posted @ 2024-10-15 17:29
你的镁偷走了我的锌
阅读(14)
评论(0)
推荐(0)

浙公网安备 33010602011771号