集合和字符串的使用

20 篇文章 0 订阅 ¥399.90 ¥499.90


一、集合概述

  • Collection接口:单列数据
    • List接口:元素有序、可重复的集合 “动态数组”
      • ArrayList、LinkedList、Vector
        // 将数组转换为List
        String[] array = { “a”, “b”, “c” };
        List list = Arrays.asList(array);

// 如果需要一个可变的List,可以这样做
List mutableList = new ArrayList<>(list);

// 将List转换为数组
List list = Arrays.asList(“a”, “b”, “c”);
String[] array = list.toArray(new String[0]);

+ Set接口:元素无序、不可重复的集合 “集合”
	+ HashSet(子类:LinkedHashSet)、TreeSet
  • Map接口:双列数据
    • HashMap、LinkedHashMap、TreeMap、Hashtable、Properties

二、Collection

需重写equals()

  • add(Objec tobj)
  • addAll(Collection coll)
  • int size()
  • void clear()
  • boolean isEmpty()
  • boolean contains(Ob
  • 25
    点赞
  • 14
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值