/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package test;
/**
*
* @author huanghuankun
*/
public class ArrayInit {
public static void main(String[] args){
int[] array = new int[1];
System.out.println("array="+array);//地址
System.out.println("array[0]="+array[0]);//数组初始化默认为0
System.out.println("array.equals(0)="+array.equals(0));//不会报编译错误或者运行时错误,返回false
}
}
输出:
array=[I@20e5f01b
array[0]=0
array.equals(0)=false

本文通过一个简单的Java程序实例,详细展示了如何初始化数组并进行基本的打印操作,包括打印数组地址、数组元素默认值及数组与数值的比较。
2174

被折叠的 条评论
为什么被折叠?



