数据结构05:数组

/**
*
* byte 0
* short 0
* int 0
* long 0L
* float 0.0f
* double 0.0d
* char '\u0000'
* String (or any object) null
* boolean false
*
*/

/**
 * int[]数组初始化
 * 

* 数组元素默认值是0 */ @Test public void test() { int[] ints = new int[10]; //[I@7e0b37bc System.out.println(ints); //[0, 0, 0, 0, 0, 0, 0, 0, 0, 0] System.out.println(Arrays.toString(ints)); //ints[0] //0 System.out.println(ints[0]); } /** * Integer[]数组初始化 *

* 数组元素默认值是null */ @Test public void test2() { Integer[] integers = new Integer[10]; //integers[0] //null System.out.println(integers[0]); } /** * char[]数组初始化 * */ @Test public void test3() { char[] chars = new char[10]; //chars[0] //'\u0000' 空白 //https://www.utf8-chartable.de/unicode-utf8-table.pl?number=128 System.out.println(chars[0]); }

你可能感兴趣的:(数据结构05:数组)