Question: Consider an array named source. Write a method/function named removeAll( source, size, element) that removes all the occurrences of the given element in the source

Consider an array named source. Write a method/function named removeAll( source, size, element) that removes all the occurrences of the given element in the source array. You must execute the method by passing an array, its size and the element to be removed. After calling the method, print the array to show whether all the occurrences of the element have been removed properly.

Example:

source=[10,2,30,2,50,2,2,0,0]

removeAll(source,7,2)

After calling removeAll(source,7,2), all the occurrences of 2 must be removed. Printing the array afterwards should give the output as:

 [ 10,30,50,0,0,0,0,0,0]

Step by Step Solution

3.44 Rating (147 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

RemoveElementjava public class RemoveElement private static int removeAllint source int ... View full answer

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 Programming Questions!