读文章

0.如果是基本数据类型的话,在数组中就存储特定的值;如果是对象的话,在数组中就是存储对象的引用。

1.数组本身就是对象

再读文章

0.Arrays.sort(array);  Arrays.toString(array);(重写了toString方法)  Arrays.copyOf(array,length);(返回复制以后的数组,也可以复制二维数组)  Arrays.copyOfRange(array, start_index,end_index);

1.数组类并没有重写equals方法,但是Arrays类重写了equals方法。Arrays.equals(array1,array2);  Arrays.deepEquals(array1,array2);  Arrays.deepToString(array1,array2);

又读文章

0.

    ArrayList的size不定的根据:

    • When the internal array is filled, ArrayList creates a new array internally. The size of the new array is the size of the old array times 1.5 plus 1.
    • All the data is copied from the old array into the new one。
    • The old array is cleaned up by the garbage collector.

  indexOf();  get();  add();  contain();  set();(与add有区别)  clear();  asList();{ArrayList<Cat> catsList = new ArrayList<>(Arrays.asList(catsArray));(使用方法)}  toArray();

  size();  

1.未解决问题:ArrayList<Cat> cats = new ArrayList<>(); ArrayList<Cat> cats = new ArrayList<Cat>();两者区别

最后再读一篇

0.You cannot simultaneously iterate over a collection and change its elements.(不能同时迭代集合并更改其中的元素,包括插入,删除等操作)

要实现迭代时还要更改其中的内容,就要用到Iterator类

  • hasNext() - returns true or false, depending on whether there is a next item in the list, or we have already reached the last one.
  • next() - returns the next item in the list
  • remove() - removes an item from the list
Iterator<Cat> catIterator = cats.iterator();// Create an iterator
while(catIterator.hasNext()) {// As long as there are elements in the list Cat nextCat = catIterator.next();// Get the next element
System.out.println(nextCat);// Display it
}

关于remove()方法:remove() removes the last element returned by the iterator.

remove()方法的使用:

Iterator<Cat> catIterator = cats.iterator();// Create an iterator
while(catIterator.hasNext()) {// As long as there are elements in the list Cat nextCat = catIterator.next();// Get the next element
if (nextCat.name.equals("Lionel Messi")) {
catIterator.remove();// Delete the cat with the specified name
}
} System.out.println(cats);

CodeGym-17~20的更多相关文章

  1. js如何判断一组数字是否连续,得到一个临时数组[[3,4],[13,14,15],[17],[20],[22]];

    var arrange = function(arr){ var result = [], temp = []; arr.sort(function(source, dest){ return sou ...

  2. 基数排序的可复用实现(C++11/14/17/20)

    基数排序,是对整数类型的一种排序方法,有MSD (most significant digit)和LSD (least significant digit)两种.MSD将每个数按照高位分为若干个桶(按 ...

  3. tail -fn 1000 test.log | grep '关键字' 按照时间段 sed -n '/2014-12-17 16:17:20/,/2014-12-17 16:17:36/p' test.log /var/log/wtmp 该日志文件永久记录每个用户登录、注销及系统的启动、停机的事件

    Linux 6种日志查看方法,不会看日志会被鄙视的 2020-02-11阅读 7.3K0   作为一名后端程序员,和Linux打交道的地方很多,不会看Linux日志,非常容易受到来自同事和面试官的嘲讽 ...

  4. [C++]PAT乙级1009. 说反话 (17/20)

    /* 1009. 说反话 (20) 给定一句英语,要求你编写程序,将句中所有单词的顺序颠倒输出. 输入格式: 测试输入包含一个测试用例, 在一行内给出总长度不超过80的字符串. 字符串由若干单词和若干 ...

  5. [C++]PAT乙级1003. 我要通过!(17/20)

    /* 1003. 我要通过!(20) “答案正确”是自动判题系统给出的最令人欢喜的回复.本题属于PAT的“答案正确”大派送 —— 只要读入的字符串满足下列条件,系统就输出“答案正确”,否则输出“答案错 ...

  6. 在LaTeX里插入全页的pdf 分类: LaTex 2015-02-04 17:20 142人阅读 评论(0) 收藏

    要帮女友排版毕业论文,需要插入封面,省时省力的方法就是把学校给的Word封面保存成PDF然后插入到Latex文档中. 首先添加下面的宏: \usepackage[final]{pdfpages} 然后 ...

  7. c++ 字符串流 sstream(常用于格式转换) 分类: C/C++ 2014-11-08 17:20 150人阅读 评论(0) 收藏

    使用stringstream对象简化类型转换 C++标准库中的<sstream>提供了比ANSI C的<stdio.h>更高级的一些功能,即单纯性.类型安全和可扩展性.在本文中 ...

  8. ListView常用属性 (2012-01-12 17:20:27)

    比较特别的属性,通过设置这样的属性可以做出更加美观的列表.stackFromBottom——设置该属性之后你最新条目就会显示你列表的最下面,值为true和false,如android:stackFro ...

  9. 《Tsinghua os mooc》第17~20讲 同步互斥、信号量、管程、死锁

    第十七讲 同步互斥 进程并发执行 好处1:共享资源.比如:多个用户使用同一台计算机. 好处2:加速.I/O操作和CPU计算可以重叠(并行). 好处3:模块化. 将大程序分解成小程序.以编译为例,gcc ...

  10. 第8次Scrum会议(10/20)【欢迎来怼】

    一.小组信息 队名:欢迎来怼 小组成员 队长:田继平 成员:李圆圆,葛美义,王伟东,姜珊,邵朔,冉华 小组照片 二.开会信息 时间:2017/10/20 17:20~17:45,总计25min. 地点 ...

随机推荐

  1. iOS中属性 (nonatomic, copy, strong, weak)的使用 By hL

    以下内容来自Stackflow的详解 1.Nonatomicnonatomic is used for multi threading purposes. If we have set the non ...

  2. shell脚本命令(sotr/unip/tr/cut/eval)与正则表达式

    shell脚本命令(sotr/unip/tr/cut/eval)与正则表达式 1.sort命令 概述: Linux sort命令用于将文本文件内容加以排序. sort命令可针对文本文件的内容,以行为单 ...

  3. puppeteerExamples

    What can I do? Most things that you can do manually in the browser can be done using Puppeteer! Here ...

  4. 关于sys.path.append()

    当我们导入一个模块时:import  xxx,默认情况下python解析器会搜索当前目录.已安装的内置模块和第三方模块,搜索路径存放在sys模块的path中: >>> import  ...

  5. ASP.NET Core 6框架揭秘实例演示[04]:自定义依赖注入框架

    ASP.NET Core框架建立在一个依赖注入框架之上,已注入的方式消费服务已经成为了ASP.NET Core基本的编程模式.为了使读者能够更好地理解原生的注入框架框架,我按照类似的设计创建了一个简易 ...

  6. Solution -「ARC 063D」「AT 2149」Snuke's Coloring 2

    \(\mathcal{Decription}\)   Link.   平面上有一个左下角坐标 \((0,0)\) 右上角坐标 \((W,H)\) 的矩形,起初长方形内部被涂白. 现在给定 \(n\) ...

  7. Linux上大文件切割以及批量并发处理

    一.环境说明 某次项目需求中,在Linux上有批文本文件,文件文件都有几个G大,几千万行的数据.无论在Linux和Windows打开这么大的文件,基本上打开要卡半天,更别说编辑. 因此想到使用spli ...

  8. rabbit-vue3-ts-小兔鲜儿2022新版-系列开篇

    rabbit-vue3-ts-小兔鲜儿2022新版 项目使用 Vite + Vue3 + TypeScript + Pinia + VueRouter@4 进行开发. 代码检查和格式化为:ESlint ...

  9. Python基础(Day1)

    一.Python的简介  1.Python的诞生 python的创始人为吉多·范罗苏姆(Guido van Rossum).1989年的圣诞节期间,吉多·范罗苏姆(中文名字:龟叔)为了在阿姆斯特丹打发 ...

  10. CentOS8 固定IP无法访问外网问题解决(ping: www.hao123.com: Name or service not known)

    CentOS8虚拟机用了一段时间后,需要安装telnet-server服务,却无法正常安装.之前安装ftp服务是没有问题的,安装问题如下: 错误提示,无法下载相关元数据:网上也是0.0B/s.那么可能 ...