You will need a new array declared before the loop, and copy the numbers into it. That is if you insist on doing it the hard way. Otherwise find the methods in the Arrays class that will do the copying for you.
The name newArray in line 3 is very misleading.
posted 2 weeks ago
Thanks so much! I will try looking for a method in Array class.
Good point, I'll change the name.
posted 1 week ago
Glenda Karen wrote:Thanks so much! . . . .
That's a pleasure There are many methods with names starting copy; maybe copyOfRange() will work. As an alternative, there is the old arraycopy() method in the System class.