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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started