读文章

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);

最新文章

  1. 性能测试工具 wrk 安装与使用
  2. Android Studio NDK编程-环境搭建及Hello!
  3. psp工具需求分析
  4. UvaOJ10369 - Arctic Network
  5. javascript对象初探(一)--- 构造器函数
  6. 东大OJ-1588: Routing Table
  7. August 7th 2016, Week 33rd Sunday
  8. 分布式PostGIS系列【2】——pgpool-II
  9. Android_2015-04-07 Android中Intent的使用
  10. [HDU1017]Exact cover[DLX][Dancing Links详解][注释例程学习法]
  11. STM32与LPC系列ARM资源之比较
  12. 在Linux中让文本显示带颜色的字。
  13. C#推送RTMP到SRS通过VLC进行取流播放!!
  14. crontabs linux定时任务功能安装
  15. python的partial()用法说明
  16. WinlogonHack获取系统密码
  17. Python开发【Django】:组合搜索、JSONP、XSS过滤
  18. Laravel 学习记录
  19. 【CQOI 2007】 余数求和
  20. PostgreSQL full_page_write记录

热门文章

  1. 聊一聊DTM子事务屏障功能之SQL Server版
  2. python基础语法_3面向对象
  3. Spring 初始化流程
  4. 基于单XCVU9P+双DSP C6678的双FMC接口 100G光纤传输加速计算卡
  5. Solution -「多校联训」光影交错
  6. 排查log4j不输出日志到文件的问题
  7. webshell安全教程防止服务器被破解
  8. ACM对抗赛有感
  9. python2写ping监控,自动发现ip
  10. 网络主动测评系统,IT网络运维管理的法宝!