You cannot call .intValue() on an Object because the intValue() method is missing from the Object class.
Instead, you need to first shift the Object to an Integer class, for example:
newarray[e] = ((Integer)array[i]).intValue();
Edit: just a good tip on StackOverflow - please limit your code to what is appropriate! Although large blocks of code are sometimes needed, this is not the case. This makes the question more enjoyable, and it should get better answers.
Also, do not use homework . Currently, it is outdated and is in the process of being burned.
source share