About Question enthuware.ocajp.i.v8.-2-.2015 :
Moderator: admin
- 
				BrentCoetzee
 - Posts: 5
 - Joined: Tue Apr 20, 2021 3:30 am
 - Contact:
 
About Question enthuware.ocajp.i.v8.-2-.2015 :
The answer would give an java.lang.ArrayIndexOutOfBoundsException: 5
			
			
									
									
						- 
				BrentCoetzee
 - Posts: 5
 - Joined: Tue Apr 20, 2021 3:30 am
 - Contact:
 
Re: About Question enthuware.ocajp.i.v8.2.2015 :
I believe the answer should be:
 
int[][] matrix = new int[5][4];
for(int i=0;i<5; i++) matrix[1] = 1;
			
			
									
									
						int[][] matrix = new int[5][4];
for(int i=0;i<5; i++) matrix[1] = 1;
- 
				admin
 - Site Admin
 - Posts: 10443
 - Joined: Fri Sep 10, 2010 9:26 pm
 - Contact:
 
Re: About Question enthuware.ocajp.i.v8.2.2015 :
Why do you believe so? Specifically, what makes you think that matrix[1]  = 1; is valid?
Try compiling and running the code exactly as given in the question/option.
			
			
									
									
						Try compiling and running the code exactly as given in the question/option.
- 
				BrentCoetzee
 - Posts: 5
 - Joined: Tue Apr 20, 2021 3:30 am
 - Contact:
 
Re: About Question enthuware.ocajp.i.v8.2.2015 :
Apologies, there should be  before [1]
			
			
									
									
						- 
				BrentCoetzee
 - Posts: 5
 - Joined: Tue Apr 20, 2021 3:30 am
 - Contact:
 
Re: About Question enthuware.ocajp.i.v8.2.2015 :
When posting a square bracket with letter i inside,it is removed as soon as i submit the post.
			
			
									
									
						- 
				BrentCoetzee
 - Posts: 5
 - Joined: Tue Apr 20, 2021 3:30 am
 - Contact:
 
Re: About Question enthuware.ocajp.i.v8.2.2015 :
Apologies, I made a mistake the answer to the question is correct in your material. DUH moment for me.
			
			
									
									
						Who is online
Users browsing this forum: No registered users and 12 guests