Thinking In Java 学习笔记(四)
接本系列上篇。
2.8 容器
1)容器不能保存基本数据类型
但是可以保存integer这种封装基本数据类型的类。
小贴士
Arrays.fill
static void
fill(int[] array, int value)Fills the specified array with the specified element.
static void
fill(int[] array, int start, int end, int value)Fills the specified range in the array with the specified element.
System.arraycopy
static void
arraycopy(Object src, int srcPos, Object dst, int dstPos, int length)Copies length elements from the array src, starting at offset srcPos, into the array dst, starting at offset dstPos.
Arrays.equals
static boolean
equals(int[] array1, int[] array2)Compares the two arrays.
Arrays.sort
static void
sort(int[] array)Sorts the specified array in ascending numerical order.
2)collection与map
Collection是一组独立的元素,通常有某种规则应用于其上。List必须保留元素特定的顺序,该顺序是指元素进入List的顺序。Set必须不能出现重复元素。
Map则是一组成对的键值对对象。
3)关于容器的总结


2.9 接口
1)接口与向上转型
类可以实现多个接口,并且该类对象可以向上转型为接口。
2)extends用于继承多个类
一般extends只能继承单一的类,但是在接口继承中则没这个限制。如下代码。
