Question: How can you remove all objects of the same type from a custom-built array? I cannot use predefined methods such as remove() I have to
How can you remove all objects of the same type from a custom-built array? I cannot use predefined methods such as remove() I have to use a for loop to search for the object and remove it from the array while returning the number of objects that were removed. I also need to remove just the first instance of this object and return true if removed, false if the object is not in the array.
/** * Removes all instances of this object from the list. * * @param obj the object to match for removal * @return the number of objects removed */ int removeAll(GenClass obj) {
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
