临近考试了,复习的时候遇到一个问题,程序是这样的:
public class Test 
{
    public static void main(String[] args)
   {
       boolean[][] x = new boolean[3][]; 
       x[0] = new boolean[1]; 
       x[1] = new boolean[2]; 
       x[2] = new boolean[3]; 
       System.out.println("x[2][2] is " + x[2][2]); 
    } 
}运行结果是:x[2][2] is false可是,这里没有赋值,为什么会有运行结果呢?

解决方案 »

  1.   

    boolean 是基本类型  默认值 是false
      

  2.   

    int 不赋值默认就是0,
    boolean不赋值默认是false..
      

  3.   

    new boolean[3]
    这样写会产生默认值的
      

  4.   

    默认值,基本类型都有默认值
    boolean  默认  false
    String   默认  null
    int      默认  0比如你创建一个  int数据   int[] intAry = new int[10];
                           System.out.println("intAry[8]  is " + intAry[8]);打印出来就是  0  
      

  5.   

    boolean 是基本类型 默认值 是false
      

  6.   

    [Quote=引用 1 楼 babyboy9685 的回复:]
    boolean 是基本类型 默认值 是false
    同意
      

  7.   

    boolean 是基本类型 默认值 是false
    正解!