CodeGym-17~20
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 listremove()- 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的更多相关文章
- js如何判断一组数字是否连续,得到一个临时数组[[3,4],[13,14,15],[17],[20],[22]];
var arrange = function(arr){ var result = [], temp = []; arr.sort(function(source, dest){ return sou ...
- 基数排序的可复用实现(C++11/14/17/20)
基数排序,是对整数类型的一种排序方法,有MSD (most significant digit)和LSD (least significant digit)两种.MSD将每个数按照高位分为若干个桶(按 ...
- 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日志,非常容易受到来自同事和面试官的嘲讽 ...
- [C++]PAT乙级1009. 说反话 (17/20)
/* 1009. 说反话 (20) 给定一句英语,要求你编写程序,将句中所有单词的顺序颠倒输出. 输入格式: 测试输入包含一个测试用例, 在一行内给出总长度不超过80的字符串. 字符串由若干单词和若干 ...
- [C++]PAT乙级1003. 我要通过!(17/20)
/* 1003. 我要通过!(20) “答案正确”是自动判题系统给出的最令人欢喜的回复.本题属于PAT的“答案正确”大派送 —— 只要读入的字符串满足下列条件,系统就输出“答案正确”,否则输出“答案错 ...
- 在LaTeX里插入全页的pdf 分类: LaTex 2015-02-04 17:20 142人阅读 评论(0) 收藏
要帮女友排版毕业论文,需要插入封面,省时省力的方法就是把学校给的Word封面保存成PDF然后插入到Latex文档中. 首先添加下面的宏: \usepackage[final]{pdfpages} 然后 ...
- c++ 字符串流 sstream(常用于格式转换) 分类: C/C++ 2014-11-08 17:20 150人阅读 评论(0) 收藏
使用stringstream对象简化类型转换 C++标准库中的<sstream>提供了比ANSI C的<stdio.h>更高级的一些功能,即单纯性.类型安全和可扩展性.在本文中 ...
- ListView常用属性 (2012-01-12 17:20:27)
比较特别的属性,通过设置这样的属性可以做出更加美观的列表.stackFromBottom——设置该属性之后你最新条目就会显示你列表的最下面,值为true和false,如android:stackFro ...
- 《Tsinghua os mooc》第17~20讲 同步互斥、信号量、管程、死锁
第十七讲 同步互斥 进程并发执行 好处1:共享资源.比如:多个用户使用同一台计算机. 好处2:加速.I/O操作和CPU计算可以重叠(并行). 好处3:模块化. 将大程序分解成小程序.以编译为例,gcc ...
- 第8次Scrum会议(10/20)【欢迎来怼】
一.小组信息 队名:欢迎来怼 小组成员 队长:田继平 成员:李圆圆,葛美义,王伟东,姜珊,邵朔,冉华 小组照片 二.开会信息 时间:2017/10/20 17:20~17:45,总计25min. 地点 ...
随机推荐
- jdbc插入或查询数据库时间总是比实际时间少8小时原因
mysql插入数据库的时间总是有问题,比实际时间要早8小时.检查是jdbc连接的url中配置的时区有问题,原先是 jdbc.url=jdbc:mysql://47.**.**.**:3306/yeey ...
- Linux curl命令进行网络请求
原创:转载需注明原创地址 https://www.cnblogs.com/fanerwei222/p/11841353.html 1. curl get请求: curl http://www.baid ...
- Volatile关键字和ThreadLocal变量的简单使用
原创:转载需注明原创地址 https://www.cnblogs.com/fanerwei222/p/11812459.html package thread; /** * volatile关键字和T ...
- 简单实现支付密码输入框 By HL
密码输入框在微信,支付宝中比较常见 主要功能点 1.6位(或者N位)密码输入框封装
- DockerClient端与DockerDaemon的通信安全
DockerClient端与DockerDaemon的通信安全 容器的安全性问题的根源在于容器和宿主机共享内核.如果容器里的应用导致Linux内核崩溃,那么整个系统可能都会崩溃.与虚拟机是不同的,虚拟 ...
- shell脚本命令(sotr/unip/tr/cut/eval)与正则表达式
shell脚本命令(sotr/unip/tr/cut/eval)与正则表达式 1.sort命令 概述: Linux sort命令用于将文本文件内容加以排序. sort命令可针对文本文件的内容,以行为单 ...
- Python支付宝单笔转账接口
开发信息 接口加签方式为证书模式 证书模式好处是可以使用支付宝的转账到支付宝账户,也就是提现功能,公钥模式不能实现转账到支付宝账户. 此DEMO利用单笔转账到支付宝账户接口[提现功能]用户可以通过此D ...
- nginx 配置文件与日志模块
内容概要 Nginx 虚拟主机 基于多 IP 的方式 基于多端口的方式 基于多域名的方式 日志配置(日志格式详解) Nginx 访问控制模块(可以去 Nginx.org 文档 documentatio ...
- python 2048游戏控制器
2048游戏控制器 1 evaluate 要用程序来处理就得对现实的问题进行量化,用数字来表示.在2048游戏中,我们的输入是一个棋局,让我们输出一个移动方向,这样我们需要对棋局进行量化,即我们要评估 ...
- Zookeeper 提供的API
上篇介绍了Zookeeper命令行相关的知识,本小作文介绍从另一个维度操作Node相关的内容:Zookeer的API.同样借用Zookeeper应用之一的数据注册与订阅中的案例类比命令行操作,重点介绍 ...