Question: Need help with these methods, instructions are provided in the comments @SuppressWarnings(unchecked) public boolean setCapacity(int newCapacity) { // Change the max number of items allowed

Need help with these methods, instructions are provided in the comments

@SuppressWarnings("unchecked")

public boolean setCapacity(int newCapacity) {

// Change the max number of items allowed before next expansion to newCapacity.

// No other changes to the current values in storage

// (i.e. they should all keep the same index).

// Capacity should not be changed if:

// - newCapacity is below MIN_CAPACITY; or

// - newCapacity is not large enough to accommodate current number of items

// Return false if newCapacity cannot be applied; return true otherwise.

// Special case: if newCapacity is identical to the current max number of items,

// no need to change anything but still return true.

// O(N) where N is the number of elements in the array

return false; //default return, remove/change as needed

}

public int firstIndexOf(T value) {

// Return the index of the first occurrence of value or -1 if not found.

// NOTES: - Remember null is not a valid item in list.

// - Remember to use .equals for comparison of non-null values.

// O(N) where N is the number of elements in the list

return 1; //default return, remove/change as needed

}

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!