读文章

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. cell重用

    少数几个cell可不重用 NSString *CellIdentifier = [NSString stringWithFormat:@"MyCellID_%d",indexPat ...

  2. PostgreSQL删除数据库失败处理

    PostgreSQL Drop DATABASE删除数据库失败,需要结束掉占用的连接 登录PostgreSQL后,执行: SELECT pg_terminate_backend(pg_stat_act ...

  3. linux上 oracle数据库的密码过期-解决

    1.登录root用户 su oracle   或者 su - oracle   切换到数据库用户 2.进入SqlPlus sqlplus / as sysdba --进入sqlplus 注意语法  / ...

  4. dfs+search

    1.数的划分 点击查看搜索 #include<iostream> #include<cstdio> #include<cmath> #include<algo ...

  5. suse 12 二进制部署 Kubernetets 1.19.7 - 第04章 - 部署docker服务

    文章目录 1.4.部署docker 1.4.0.下载docker二进制文件 1.4.1.配置docker镜像加速 1.4.2.配置docker为systemctl管理 1.4.3.启动docker服务 ...

  6. 利用shell脚本使用kubeadm部署kubenetes 1.18.6集群环境

    # README # 此脚本需要在master节点上使用 # 注意root密码,请提前修改 # 个人实验环境,注意机器最低配置:master(2G内存,1cpu2核心,否则集群会创建失败),node( ...

  7. LibOpenCM3(二) 项目模板 Makefile分析

    目录 LibOpenCM3(一) Linux下命令行开发环境配置 LibOpenCM3(二) 项目模板 Makefile分析 LibOpenCM3 项目模板 项目模板地址: https://githu ...

  8. validator参数校验

    目录 validator参数校验 validator参数校验 type Req struct { Sn string `json:"sn" binding:"requir ...

  9. 性能测试:k8s集群监控环境搭建(kube-prometheus)

    选择kube-prometheus版本 k8s集群版本是1.22.x 5个节点 说明:如果你电脑配置低,也可以1个master节点,2个node节点 3个节点 Kube-Prometheus地址:ht ...

  10. [Matlab]二维统计分析图实例

    常见的二维统计分析图形: bar(x,y,选项) 条形图 stairs(x,y,选项) 阶梯图 stem(x,y,选项) 杆图 fill(x1,y1,选项1,x2,y2,选项2,--) 填充图 实例: ...