java数组初始化

java数组初始化

        //静态初始化数组:方法一  
        String cats[] = new String[] {  
                "Tom","Sam","Mimi"  
        };  
          
        //静态初始化数组:方法二  
        String dogs[] = {"Jimmy","Gougou","Doggy"};  
          
        //动态初始化数据  
        String books[] = new String[2];  
        books[0] = "Thinking in Java";  
        books[1] = "Effective Java";  
          
        System.out.println(cats.length);  
        System.out.println(dogs.length);  
        System.out.println(books.length);       

 

posted @ 2016-07-07 11:10  xiluhua  阅读(189)  评论(0编辑  收藏  举报