Question: A popular implementation of List is ArrayList. Look up how to instantiate one. * * @return a List object. */ public List createList(){ } return
A popular implementation of List is ArrayList. Look up how to instantiate one.
*
* @return a List
*/
public List
}
return null;
}
/**
* Get the size of a list.
*
* @param list a List
* @return the size of List (number of items it holds.)
*/
return 0;
}
/**
* Add an item to a list.
* When we add a value to a list, it gets appended to the end.
*
* @param list a List
* @param value an integer that we would like to add to list.
* @return nothing, pass by reference will cause changes to the list object to be reflected across the program.
*/
public void addToList(List
}
/**
* Get a particular index of a list.
* Lists, like arrays, are zero-indexed, so they start counting at zero. For instance,
* index 0 of {0,2,4,6} is 0.
* index 1 of {0,2,4,6} is 2.
* Index is the same as saying the position, number, etc of a value.
* Let's get the element from a list at a certain index.
*
* @param list a List
* @param index represents the index of the element we would like to retrieve.
* @return the int at the location in 'list' represented by 'index'.
*/
public int get(List
return 0;
}
/**
* Remove an index from a list.
* We can remove an item from the list, which will cause all items after it to reduce their index by 1 (they are
* all still ordered, without any empty spaces in the list.)
*
* @param list a List
* @param position represents the index of the element we would like to remove.
* @return nothing, pass by reference will cause changes to the list object to be reflected across the program.
*/
public void removeFromList(List
}
/**
* Update an index of a list.
* We can update a value in the list, which will overwrite a value at a certain position.
*
* @param list a List
* @param position represents the index of the element we would like to change.
* @param value the new value which we would like to assign to the item at position in list
* @return nothing, pass by reference will cause changes to the list object to be reflected across the program.
*/
public void updateAtPosition(List
}
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
