• Register
0 votes
11 views
Thank you in advance for any help?
10 4 3
13,500 points

Please log in or register to answer this question.

1 Answer

0 votes

Answer:

I actually recollect the primary long stretches of my programming courses and I absolutely see how you feel. Here is the code that tackles your concern. To gain from this answer, attempt to run it adding a few 'print' insider savvy, so you can see the improvement of the factors. 

First, you ought to find out about circles, for this situation most appropriate is for circle. For example, we should introduce the entire table with expanding values beginning with 0:

final int SIZE = 10;
int[] array = new int[SIZE];
for (int i = 0; i < SIZE; i++) {
    array[i] = i;
}

Presently you can alter it to instate your table with values according to your task. In any case, what occurs in the event that you supplant condition I < SIZE with I < 11? All things considered, you will get IndexOutOfBoundException, as you attempt to access (sooner or later) an article under record 10, however, the most noteworthy file in the 10-component exhibit is 9. So you are trying, all in all, to locate companion's home with number 11, however, there are just 10 houses on the road. 

In the event of the code, you introduced, all things considered, there should be a greater amount of it, as you can not get this mistake (special case) from that code. 

Hope this will help you. 

9 4 4
27,280 points

Related questions

0 votes
1 answer 10 views
10 views
Problem: public class dereks { public static void main (String [] args){ int array [] = {1,2,3,5,6,7}; int sum =0; for(int counter=0; counter<=array.length; counter++){ sum+=array[counter]; } System.out.println(sum); } } Can anyone tell ... I can't understand why I'm getting the error message "Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 5 at dereks.main(dereks.java:7)" .
asked Feb 20 Ali 6.5k points
0 votes
1 answer 24 views
24 views
Problem: I am a beginner to programming. I'm a few weeks into my first programming class, so please bear with me. I am not a person to ask for help, so I have searched for an answer extensively with no luck. This is also my first time posting ... correct for future posts. This is what I got while running the program. Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException:50 on line 23
asked Feb 20 Ali 6.5k points
0 votes
1 answer 17 views
17 views
Prblem: The error ArrayIndexOutOfBoundsException: 1 means index 1 is invalid and it's out of bounding i.e. more than the length of the array. Since the array has a zero-based index in Java, this means you are trying to access the second element of an array which only contains one element.
asked Feb 19 Ali 6.5k points
0 votes
1 answer 5 views
5 views
Problem: I am a beginner to programming. I'm a few weeks into my first programming class, so please bear with me. I am not a person to ask for help, so I have searched for an answer extensively with no luck. This is also my first time posting anything in any type of forum, so if my question structure is off I'm sorry and I will correct for future posts.
asked Feb 18 Ali 6.5k points
0 votes
1 answer 13 views
0 votes
1 answer 34 views
1 vote
1 answer 22 views
22 views
Problem : I have very recently started to learn programming in Java. I am trying to execute my java code but I am facing the below error. &ldquo;Exception in thread "main" java.lang.arrayindexoutofboundsexception:&rdquo; I am unable to understand above error. Please find below my code: ... according to my debugger*/ myodd[j] = input[i]; j++; } return myodd; } Please help me in fixing above error.
asked Mar 30, 2020 morrisBson 3.2k points
0 votes
1 answer 46 views
46 views
Problem : Currently I am learning Java. I have written code in Java but it gives me below error &ldquo;Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 0 at Minesweeper.main(Minesweeper.java:5)&rdquo;. I am unable to understand above error. How can I fix above error.
asked Feb 22, 2020 mphil 2.3k points
0 votes
1 answer 103 views
103 views
Problem : I am a beginner to Java programming. While executing my program i got below error exception in thread "main" java.lang.arrayindexoutofboundsexception: 10
asked Oct 23, 2019 peterlaw 6.9k points
0 votes
1 answer 1 view
1 view
Problem : Any ideas on what I need to do to fix this? Thanks!
asked 58 minutes ago Wafa Abu Yousef 2.1k points