Why doesn't the code work? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Why doesn't the code work?

I can not solve the programming problem. I need to remove all the even numbers from the array. What is the error in the code? Why is the index outside the bounds of the array? https://code.sololearn.com/cXGx1U9Gp81Y/#cs

10th Dec 2019, 2:42 PM
Mary_d9
Mary_d9 - avatar
2 Answers
+ 2
Line 37 int oddnumbers = 0; Line 38 int[] newmas = new int[oddnumbers]; <oddnumbers> value is zero, so your <newmas> array is empty.
10th Dec 2019, 3:01 PM
Ipang
+ 1
Ipang , ah, really, thanks)
10th Dec 2019, 5:09 PM
Mary_d9
Mary_d9 - avatar