zoukankan      html  css  js  c++  java
  • 集合

    Collection----Java中对一些数据结构和算法进行了封装即是集合。集合也是一种对象,用于存储、检索和传输对象。
    1、长度可变2、类型可不同3、内存空间可不固定
    ----常用函数add();clear();contains();iterator()迭代,遍历元素;remove();size();toArray();
    ----迭代函数iterator----常用函数hasNext();next();remove(),当迭代遍历元素时如果想删除,必须用迭代里面的remove函数。
    一、List
    1、ArrayList
    ----常用函数contains(Object o);get(int index);set(int index, E element)
    2、LinkedList
    ----常用函数addFirst(E e) ;addLast(E e) ;getFirst();getLast();pop();push(E e);removeFirst();removeLast()
    二、Set
    1、HashSet
    2、TreeSet
    Map---一组“键对象Key+值对象Value”,Key不可以重复,Value可以重复
    ----常用函数put(K key, V value);keySet();values();
    一、HashMap
    二、TreeMap
    各类的区别
    一、List与Set。
    1、List是有序的,Set是无序的,这里的顺序是指放入与拿出的索引顺序
    2、List里面的元素是可以重复的,Set里面的元素是不可以重复的
    二、ArrayList与LinkedList
    1、ArrayList适合查询和修改,LinkedList适合增加和删除
    三、HashSet与TreeSet
    1、HashSet是按哈希码来存放元素,TreeSet是按字典顺序来存放元素
    2、HashSet速度快,TreeSet速度慢

  • 相关阅读:
    insertAfter()
    Unity3D之协程(Coroutines & Yield )
    C#中 As 和强制转换的总结
    Mesh系列文章
    在Unity3D 4中关联Visual Studio 2012来编写C#
    Unity3D安装多版本
    Time.deltaTime 增量时间
    Unity3D中Update和Lateupdate的区别
    Making raycast ignore multiple layers
    Unity3d中SendMessage 用法简单笔记
  • 原文地址:https://www.cnblogs.com/quanby/p/5411062.html
Copyright © 2011-2022 走看看