第八章集合操作 急 1.对数组对象的操作(Arrays), 2.对象集合(Set) 3.对象列表(儿ist) 4.对象映射(Map) 5.对对象数组的操作(Collections) 6.枚举(Enumeration)和送代(Iterator) 7.小结
1 1. 对数组对象的操作(Arrays) 2. 对象集合(Set) 3. 对象列表(List) 4. 对象映射(Map) 5. 对对象数组的操作(Collections) 6. 枚举(Enumeration)和迭代(Iterator) 7. 小结 第八章 集合操作
对数组对象的操作(Arrays) 急 ■java.util.Arrays This class contains various methods for manipulating arrays ■排序(sorting). ■ 搜索(searching) ■ 填充(filling) 2
2 ◼ java.util.Arrays类 ◼ This class contains various methods for manipulating arrays ◼ 排序(sorting) ◼ 搜索(searching) ◼ 填充(filling) 对数组对象的操作(Arrays)
boolean[],char[],byte[],short[],int[],long[],double[],float[] Object[] 全部是静态方法 ■ public static int binarySearch(byte[]a,byte key) Searches the specified array of bytes for the specified value using the binary search algorithm. public static boolean equals(byte[]a,byte[]a2) Returns true if the two specified arrays of bytes are equal to one another. ◆ public static void fill(byte[]a,byte val) Assigns the specified byte value to each element of the specified array of bytes. public static void fill(byte[]a,int fromIndex,int toIndex, byte val) Assigns the specified byte value to each element of the specified range of the specified array of bytes. public static void sort(byte[]a) Sorts the specified array of bytes into ascending numerical order. 3
3 ◼ 全部是静态方法 ◼ public static int binarySearch(byte[] a, byte key) Searches the specified array of bytes for the specified value using the binary search algorithm. ◼ public static boolean equals(byte[] a, byte[] a2) Returns true if the two specified arrays of bytes are equal to one another. ◼ public static void fill(byte[] a, byte val) Assigns the specified byte value to each element of the specified array of bytes. ◼ public static void fill(byte[] a, int fromIndex, int toIndex, byte val) Assigns the specified byte value to each element of the specified range of the specified array of bytes. ◼ public static void sort(byte[] a) Sorts the specified array of bytes into ascending numerical order. 对数组对象的操作(Arrays) boolean[], char[], byte[], short[], int[], long[], double[], float[] Object[]
对教组对象的操作(Arrays) import java.util.Arrays; public class ArrayDemo1 public static void main(String args[]) int[]a1 new int[10] int[]a2 new int[10]; Arrays.fill(a1,47); Arrays.fill(a2,47); System.out.printIn(Arrays.equals(a1,a2); a2[3]=11;a2[2]=9; System.out.println(Arrays.equals(a1,a2)); Arrays.sort(a2); System.out.println(Arrays.binarySearch(a2,11)); 4
4 对数组对象的操作(Arrays) import java.util.Arrays; public class ArrayDemo1 { public static void main(String args[]) { int[] a1 = new int[10]; int[] a2 = new int[10]; Arrays.fill(a1, 47); Arrays.fill(a2, 47); System.out.println(Arrays.equals(a1, a2)); a2[3]=11; a2[2]=9; System.out.println(Arrays.equals(a1, a2)); Arrays.sort(a2); System.out.println(Arrays.binarySearch(a2, 11)); } }
第八章集合操作 急 1.对数组对象的操作(Arrays). 2.对象集合(Set) 3.对象到表(List) 4.对象映射(Map) 5.对对象数组的操作(Collections) 6.枚举(Enumeration)和送代(Iterator) 7.小结
5 1. 对数组对象的操作(Arrays) 2. 对象集合(Set) 3. 对象列表(List) 4. 对象映射(Map) 5. 对对象数组的操作(Collections) 6. 枚举(Enumeration)和迭代(Iterator) 7. 小结 第八章 集合操作