新手,问一个比较菜的问题?
//1、	写一个矩形的类,打印两个矩形,3*4,5*7. 
 public   class   dayin   { 
 	public   static   void   main(String[]   args){ 
 		int[][]   a   =   new   int[3][4]; 
 		for(int   i=0;i <=a.length;i++){ 
 			for(int   j=0;j <=a[0].length;j++){				 
 				System.out.print(a[i][j]+ "    "); 
 			} 
 			System.out.println(); 
 		} 
 	} 
 } 
 不知道哪里错了?一期刚结业,到二期学Java   感到不太适应,可能是一期的基础不太好,希望大家多多指教!
------解决方案--------------------public class dayin { 
 	public static void main(String[] args) { 
 		int[][] a = new int[3][4]; 
 		for (int i = 0; i  < a.length; i++) { 
 			for (int j = 0; j  < a[i].length; j++) { 
 				System.out.print(a[i][j] +  "  "); 
 			} 
 			System.out.println(); 
 		} 
 	} 
 }
------解决方案--------------------如果只想效果是这样的话: 
 **** 
 **** 
 **** 
 根本不用什么数组,这样就行了 
 class dayin{ 
 	public static void main(String[] args){ 
 		for(int i=0;i <3;i++) 
 		{ 
 			for(int j=0;j <4;j++) 
 				System.out.print( "* "); 
 			System.out.println(); 
 		} 
 	} 
 }
------解决方案--------------------public class dayin { 
 public static void main(String[] args){ 
 int[][] a = new int[3][4]; 
 for(int i=0;i <a.length;i++){ 
 for(int j=0;j <a[0].length;j++){ 
 System.out.print(a[i][j]+ "  "); 
 } 
 System.out.println(); 
 } 
 } 
 } 
 把等号去掉就行了,否则产生数组下标越界的错误
------解决方案--------------------public class dayin { 
 public static void main(String[] args){ 
 int[][] a = new int[3][4]; 
 for(int i=0;i <a.length;i++){ 
 for(int j=0;j <a[0].length;j++){ 
 System.out.print( '* '); 
 } 
 System.out.println(); 
 } 
 }   
 搞定~~