Question: INSTRUCTIONS: (Generic ArrayBag class) In this assignment your are to implement ArrayBag as a generic class with a parameter T for the elements in the

INSTRUCTIONS: (Generic ArrayBag class)

In this assignment your are to implement ArrayBag as a generic class with a parameter T for the elements in the bag

1) keep two private data fields, each with the properly seleced type

2) Add a getter and setter method for the array, as well as getter and setter method for the array elements of index k

here is my code so far....

public class ArrayBag implements Cloneable { private Object[ ] data; private int manyItems; public Object getArrayBag(){ //need help here, do not know if correct, researched textbook and interent data = (T[]) new Object[manyItems]; return data; } public void setArrayBag(Object arr){ //Do not know how to return the array without errors }

public getArrElements(){ //Very stuck with get and set methods for array elements of index k

}

public setArray(){

}

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!