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.