Quantcast
Channel: Programming Forums
Viewing all articles
Browse latest Browse all 51036

Question regarding arrays

$
0
0
I have a program that I am wrote and i want to assign each element in the array the same value as the index. For some reason it will not work and I am not sure why. Here is a snippet of the for loop going through the array of 6 ints and the return.
I already declared the variable i and intitialized it what is wrong?


 int[] arrayOfIndexes = new int[5];
  
 for(int i = 0; i < 6; i++) { 
  arrayOfIndexes[i] = i;
 
}
  return i;



Viewing all articles
Browse latest Browse all 51036

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>