Page 1 of 1
					
				About Question enthuware.ocajp.i.v7.2.1381 :
				Posted: Fri May 06, 2016 3:58 pm
				by kirankumar
				int [] [] array = {{0}, {0, 1}, {0, 1, 2}, {0, 1, 2, 3}, {0, 1, 2, 3, 4}};
Is it two dimensional array? if yes, how?
			 
			
					
				Re: About Question enthuware.ocajp.i.v7.2.1381 :
				Posted: Fri May 06, 2016 4:05 pm
				by kirankumar
				The above statement is equivalent to below steps:
int [][] a = new int[5][5];
	a[0] = new int[1];
	a[1] = new int[2];
	a[2] = new int[3];
	a[3] = new int[4];
	a[4] = new int[5];
	
	a[0][0] = 0;
	
	a[1][0] = 0;
	a[1][1] = 1;
	
	a[2][0] = 0;
	a[2][1] = 1;
	a[2][2] = 2;
	
	a[3][0] = 0;
	a[3][1] = 1;	
	a[3][2] = 2;
	a[3][4] = 3;	
	
	a[4][0] = 0;
	a[4][1] = 1;	
	a[4][2] = 2;
	a[4][4] = 3;
	a[4][5] = 4;
Can you please correct me If I am wrong?
			 
			
					
				Re: About Question enthuware.ocajp.i.v7.2.1381 :
				Posted: Fri Mar 02, 2018 1:07 pm
				by Meghana
				Why does it not compile though? 
(I had selected option 1: 1 1)
			 
			
					
				Re: About Question enthuware.ocajp.i.v7.2.1381 :
				Posted: Fri Mar 02, 2018 11:00 pm
				by admin
				This is a two dimensional array but the array pointed to by the variable arr1 is not. So arr1[4][1] cannot compile. This is explained in the explanation.
			 
			
					
				Re: About Question enthuware.ocajp.i.v7.2.1381 :
				Posted: Sun Mar 04, 2018 12:29 am
				by Meghana
				Oh.. Thank you! 

 
			 
			
					
				Re: About Question enthuware.ocajp.i.v7.2.1381 :
				Posted: Wed May 15, 2019 6:26 am
				by flex567
				This would be the case in which ArrayIndexOutOfBoundsException would be thrown?
Code: Select all
System.out.println (array[4][10]);
In what case would the IllegalArgumentException be thrown?
 
			 
			
					
				Re: About Question enthuware.ocajp.i.v7.2.1381 :
				Posted: Wed May 15, 2019 7:20 am
				by admin
				
			 
			
					
				Re: About Question enthuware.ocajp.i.v7.2.1381 :
				Posted: Sun Oct 20, 2019 5:01 am
				by IrinaFF
				I get a compilation error on line "System.out.println (arr1[4][1]);"
Array type expected; found: 'int'
			 
			
					
				Re: About Question enthuware.ocajp.i.v7.2.1381 :
				Posted: Sun Oct 20, 2019 11:57 am
				by admin
				IrinaFF wrote: ↑Sun Oct 20, 2019 5:01 am
I get a compilation error on line "System.out.println (arr1[4][1]);"
Array type expected; found: 'int'
 
Please post complete and exact code that you are trying to compile.