Question: java Given the array int arr1[] = {24, 18, 12, 3, 7}; invoke a method to remove 12 from arr1 expected output should be {24,18,3,7}

java

Given the array int arr1[] = {24, 18, 12, 3, 7};

invoke a method to remove 12 from arr1 expected output should be {24,18,3,7}

but my output comes out like this arr1= {24, 0, 0, 0}

so far my remove method looks like this:

public static int[] remove(int[] nums,int value){ //a new array that is one smaller than the size of the scores array int [] numsCopy = new int[nums.length-1]; for(int k = 0; k

I need help on copying all the items except the value to be removed into

the new array.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!