数组初始化默认值及地址问题

来源:互联网 发布:linux 安装gtk3 编辑:程序博客网 时间:2024/06/13 02:09
/* * 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

0 0