and you could do the next:
int[] evens = new int[25];
// as Verruckt pointed out, you don't need one of size 50
int location = 0;
for ( int i = 2; i < 50; i = i + 2){
evens[location] = i;
location += 1;
}
there's not really the need to perform a check for evens.
with the (i % 2) test you'll get the right contents, but it's easier just to add 2 every time during the loop
Reputation Points: 919
Solved Threads: 354
Nearly a Posting Maven
Offline 2,487 posts
since Jan 2007