Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I need to find and remove all instances of an object from an array without using ArrayLists or any of their functions. I need to

I need to find and remove all instances of an object from an array without using ArrayLists or any of their functions. I need to create a loop that iterates through the array and finds the matching objects. It is supposed to remove all matching objects and return the number of matching objects removed. This is the code I have so far please make sure if you answer this that it is NOT using ArrayList functions I have created my own basic array and am programming the method removeAll() manually.

/** * 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) { int removedObj = 0; //it should be array.length not count for the loop for (int i = 0; i < array.length; i++) { if (array[i] == obj) { delete(i); removedObj++; } } return removedObj; }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Design Query Formulation And Administration Using Oracle And PostgreSQL

Authors: Michael Mannino

8th Edition

1948426951, 978-1948426954

More Books

Students also viewed these Databases questions